How can I download a new remote branch without merging?

I've been working on the master branch in my Git repository for a while. It's hosted on GitHub and cloned on two of my computers. Now I started a new branch on one computer and pushed it to GitHub. Now they know both branches, but the other computer still only knows about the master branch, not the feature branch.

When I try to pull the feature branch from GitHub, Git will merge it into my master, which is not what I want.

How can I download the feature branch from GitHub into my local repository and end up having the two branches and no merge? I'm going to merge them when it's ready, not now.

If possible, I'm interested in what to do with TortoiseGit.


You can do git fetch origin on the command line. This will update your local copy so that it knows about the new branch. Then, if you want to checkout the new branch, simply git checkout BRANCHNAME should track the remote.


A git fetch wouldn't merge anything:

git fetch
git checkout -b yourSecondBranch origin/yourSecondBranch 
# or simpler, since git 1.6+:
git checkout yourSecondBranch

(Here I fetch by default the remote 'origin', which should reference the GitHub repo)

See more at "git checkout remote branch"

链接地址: http://www.djcxy.com/p/3846.html

上一篇: 从URL获取协议,域和端口

下一篇: 如何在不合并的情况下下载新的远程分支?