标签云

微信群

扫码加入我们

WeChat QR Code

如何在git基于远程分支[复制]创建一个分支

This question already has an answer here:

The remote repo has a branch which doesn't exist on the local repo. I need to fetch it and start working with it without merging it with any other branches that I have. How can I do it?


It's not really an anonymous branch. After all you called it something. It is a remote tracking branch actually.

2018年05月27日31分41秒

After checking out the remote branch with git checkout <remote>/<branch> I am on an unnamed, "anonymous", branch, I guess.

2018年05月27日31分41秒

After checking our remote/branch you are in detached head. This is not generally speaking useful

2018年05月27日31分41秒

That does most of the job, but the resulting local branch is not tracking the remote-tracking branch. In general, the way to do this is git fetch <remote> followed by git checkout <branch>. I'll add an answer.

2018年05月28日31分41秒

how can I checkout to a branch that doesn't exist localy yet?

2018年05月27日31分41秒

Answer updated.

2018年05月28日31分41秒