远程存储库包含各种分支,如origin/davis_branch:
$ git branch -r
origin/HEAD -> origin/master
origin/daves_branch
origin/master
如何将daves_branch获取到本地存储库,以便它跟踪origin/davis_branch?
我尝试了:
$ git fetch origin discover
$ git checkout discover
远程存储库包含各种分支,如origin/davis_branch:
$ git branch -r
origin/HEAD -> origin/master
origin/daves_branch
origin/master
如何将daves_branch获取到本地存储库,以便它跟踪origin/davis_branch?
我尝试了:
$ git fetch origin discover
$ git checkout discover
当前回答
我键入了
git checkout <branch_name>
并且得到
Branch <branch_name> set up to track remote branch <branch_name> from origin.
Switched to a new branch '<branch_name>'
其他回答
你用“git pull”来保持你的分支分开。我将使用实际的存储库和分支名称来帮助,因为“lbranch”和“rbranch”很难破译。
让我们使用:myteam.unfuddle.com=远程Git服务器tlc=存储库所在的未归档项目帐户daves_branch=远程分支名称
无论有多少分支,您或任何同事都可以运行此命令仅拉动您的分支:
git init
git pull git@myteam.unfuddle.com:myteam/tlc daves_branch:refs/remotes/origin/daves_branch
我键入了
git checkout <branch_name>
并且得到
Branch <branch_name> set up to track remote branch <branch_name> from origin.
Switched to a new branch '<branch_name>'
使用gitbranch-a(本地和远程分支)或gitbranch-r(仅远程分支)查看所有远程及其分支。然后,您可以对远程执行git checkout-t remotes/repo/branch并创建本地分支。
还有一个git-ls-remote命令,用于查看该远程的所有ref和标记。
假设你的遥控器git@xyz.git你想要它的random_branch分支。流程应如下:
首先检查遥控器列表git远程-v如果你没有git@xyz.git在上述命令的输出中,您可以通过git远程添加xyzgit@xyz.git现在,您可以通过git获取xyz现在通过git checkout-b my_copy_random_branch xyz/random_brance检查分支列表查看所有的分支
本地分支my_copy_random_branch将跟踪远程的random_brance分支。
在我看来,这一行命令是获取和签出本地不存在的远程分支的最简单方法:git获取和git签出remote_branch