tags:

views:

3113

answers:

3

I've got two branches that are fully merged together.

However, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would just be easier to change to the new version in the other branch, and then re-insert my one line change after bringing it over into my branch.

So what's the easiest way in git to do this?

+43  A: 

Figured it out. Run this from the branch where you want the file to end up:

git checkout otherbranch myfile.txt
madlep
this command solved something i've been looking for hours, thx !!
Frederic Morin
But wouldn't this overwrite all your changes in the master?
Mobbit
Yes, it would. But that was the intention of the question.
Ikke
What's kinda sad is that I went to upvote this answer and it turns out I already upvoted it 6 months ago.
Mark Beckwith
A: 

What about :

  git diff "$branch" | diffstat
  git checkout --merge "$branch" "$file"
  git diff "$branch" | diffstat

-- http://rzr.online.fr/q/git

rzr
+1  A: 

But this would not transfer the commit history of the file in otherbranch. What I would love to see is a way to just "merge" a single file from one branch to another keeping its revision history.