tags:

views:

135

answers:

3

There is a branch on remote I would like to work on. It is old and I no longer have an old copy of it on my local machine. It is really far behind master. Whenever I attempt to pull it I get conflicts. I just want to create an exact duplicate of the remote branch on my local system. Why would that lead to conflicts?

I tried:

git pull origin branch_name:branch_name

That created a new branch on my local machine with the right name, but it led to conflicts.

+7  A: 
git fetch origin
git checkout -b newoldbranch oldoldbranch
Michael Krelin - hacker
+1  A: 

Can't you simply check it out ?

git checkout branch_name

?

Brian Agnew
This sort of worked, but I had to change it:git branch branch_name origin/branch_namegit checkout branch_name
apphacker
It's not that I mind, but isn't it funny that you accepted this answer, although you had to change it to mine? ;-) git branch + git checkout is equivalent to git checkout -b ;-)
Michael Krelin - hacker
+1  A: 

git pull repo branch is basically shorthand for git fetch repo branch and git merge repo/branch. I'm not one to often say RTFM, especially with git, but it is the first line of the git-pull docs. "git-pull - Fetch from and merge with another repository or a local branch". The implicit merge is causing the conflict. You just want a fetch & checkout as Michael said.

Schwern
Thanks. I hate git.
apphacker
Yeah, it'll do that. Trust me, its worth the effort. So much simpler than SVN once you get it.
Schwern