远程存储库包含各种分支,如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 pull origin your_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 fetch origin branchName
git checkout branchName
您可以通过以下方式查看它是否已存在于远程:
git branch -r
这会将远程分支提取到本地,并自动跟踪远程分支。
使用此简单命令:
git checkout -b 'your_branch' origin/'remote branch'
要签出远程而非本地存在的myBranch,这对我很有用:
git fetch --all
git checkout myBranch
我收到了这条消息:
Branch myBranch set up to track remote branch myBranch from origin
Switched to a new branch 'myBranch'
如果你已经知道你的远程分支了。。。
git remote
=> One
=> Two
并且您知道要签出的分支名称,例如br1.2.3.4,然后执行
git fetch One
=> returns all meta data of remote, that is, the branch name in question.
剩下的就是结账
git checkout br.1.2.3.4
然后用它做新的树枝。