git 查看远程仓库

查看当前项目有哪些远程仓库

$ git remote 
bixiaopeng@bixiaopengtekiMacBook-Pro wirelessqa$ git remote
origin

查看远程仓库

$ git remote -v 
bixiaopeng@bixiaopengtekiMacBook-Pro wirelessqa$ git remote -v
origin     git@gitlab.***.com:xiaopeng.bxp/wirelessqa.git (fetch)
origin     git@gitlab.***.com:xiaopeng.bxp/wirelessqa.git (push)

查看远程仓库信息

$ git remote -v <remote-name>
bixiaopeng@bixiaopengtekiMacBook-Pro wirelessqa$ git remote show origin
* remote origin
  Fetch URL: git@gitlab.****.com:xiaopeng.bxp/wirelessqa.git
  Push  URL: git@gitlab.***.com:xiaopeng.bxp/wirelessqa.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 (local out of date) 

添加远程仓库:

$ git remote add [remote-name] [url]
bixiaopeng@bixiaopengtekiMacBook-Pro robotium$ git remote add test git://github.com/paulboone/ticgit.git
bixiaopeng@bixiaopengtekiMacBook-Pro robotium$ git remote -v
origin     https://github.com/RobotiumTech/robotium (fetch)
origin     https://github.com/RobotiumTech/robotium (push)
test     git://github.com/paulboone/ticgit.git (fetch)
test     git://github.com/paulboone/ticgit.git (push)

删除远程仓库:

$ git remote rm [remote-name]
bixiaopeng@bixiaopengtekiMacBook-Pro robotium$ git remote rm test
bixiaopeng@bixiaopengtekiMacBook-Pro robotium$ git remote -v
origin     https://github.com/RobotiumTech/robotium (fetch)
origin     https://github.com/RobotiumTech/robotium (push)

修改远程仓库:

$ git remote set-url --push [remote-name] [newUrl]

重命名远程仓库

$ git remote rename <old-remote-name> <new-remote-name>

从远程仓库抓取数据 :

$git fetch [remote-name]

说明:

  1. 此命令会到远程仓库中拉取所有你本地仓库中还没有的数据。运行完成后,你就可以在本地访问该远程仓库中的所有分支
  2. fetch 命令只是将远端的数据拉到本地仓库,并不自动合并到当前工作分支,只有当你确实准备好了,才能手工合并

拉取远程仓库:

$ git pull [remote-name] [本地分支名]

说明: 一般我们获取代码更新都是用git pull, 目的是从原始克隆的远端仓库中抓取数据后,合并到工作目录中的当前分支

推送远程仓库:

$ git push [remote-name] [本地分支名]

说明: 只有在所克隆的服务器上有写权限,或者同一时刻没有其他人在推数据,这条命令才会如期完成任务。 如果在你推数据前,已经有其他人推送了若干更新,那你的推送操作就会被驳回。你必须先把他们的更新抓取到本地git pull,合并到自己的项目中,然后才可以再次推送。

$git push origin test:master         // 提交本地test分支作为远程的master分支
$git push origin test:test              // 提交本地test分支作为远程的test分支

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值