【Git】远程分支
转载:https://www.cnblogs.com/yangchongxing/p/10239270.html
目录
============================
============================
1.1、显示每一个远程服务器的简写
$ git remote
$ git remote show
origin
1.2、显示需要读写远程仓库使用的 Git 保存的简写与其对应的 URL
$ git remote -v origin https://gitee.com/yangchongxing/ycx-test.git (fetch) origin https://gitee.com/yangchongxing/ycx-test.git (push)
1.3、获得远程分支的更多信息
$ git remote show origin * remote origin Fetch URL: https://gitee.com/yangchongxing/ycx-test.git Push URL: https://gitee.com/yangchongxing/ycx-test.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 (fast-forwardable)
1.4、显式地获得远程引用的完整列表
$ git ls-remote origin 9525a36f34106c59ce28dbd76b5f70a00bb2909b HEAD 9525a36f34106c59ce28dbd76b5f70a00bb2909b refs/heads/master
格式:git remote add <shortname> <url>,shortname 简写,url 仓库地址
$ git remote add pb https://github.com/paulboone/ticgit
现在你可以在命令行中使用字符串 pb 来代替整个 URL。可以运行
$ git fetch pb
格式:git fetch [remote-name]
$ git fetch origin
把抓取到的服务器分支,新建一个自己的分支工作
格式:git checkout -b [branch] [remotename]/[branch]
$ git checkout -b newlocalfix origin/serverfix
这会给你一个用于工作的本地分支newlocalfix,并且起点位于 origin/serverfix。
格式:git push [remote-name] [branch-name]
$ git push origin master
$ git push origin localfix:serverfix
推送本地的 localfix 分支,将其作为远程仓库的 serverfix 分支,可以通过这种格式来推送本地分支到一个命名不相同的远程分支
$ git remote rename pb paul
值得注意的是这同样也会修改你的远程分支名字。 那些过去引用 pb/master 的现在会引用 paul/master。
$ git remote rm paul