Git-远程仓库的使用
Git修改远程仓库地址
1.修改命令
git remote set-url origin [url]
例如:$ git remote set-url origin gitlab@gitlab.chumob.com:php/hasoffer.git
2.先删后加
git remote rm origin
git remote add origin [url]
Git查看远程仓库的名称和对应的克隆地址
1.查看远程仓库的名称
git remote
2.查看远程仓库的克隆地址
git remote -v
Git添加远程仓库
git remote add [shortname] [url]
例如:$ git remote add pb git://github.com/paulboone/ticgit.git
解释: pb指代对应的仓库名称,我们如果推送到远程仓库,就可以选择pb这仓库,git push pb master 这样就推送到 远程pb仓库的master分之了。
Git查看远程仓库信息
git remote show [remote-name]
例如:$ git remote show origin
* remote origin
Fetch URL: https://gitee.com/huayicompany/think-in-java-4th.git
Push URL: https://gitee.com/huayicompany/think-in-java-4th.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
Git删除远程仓库和重命名
1. 删除远程仓库
git remote rm [repository name]
2.重命名远程仓库
git remote rename [old name] [new name]
Git 推送远程仓库
git push [repository name] [branch name]
Git 拉取远程仓库
git pull [repository name] [branch name] 或者
git fetch
解释:git pull 会自动合并远程仓库的内容到本地仓库,fetch不会自动合并
Git查看远程与本地的差异
git fetch origin
git diff master origin/master --minimal
参考: