Git restore one file that was deleted during merge

I'm at the 'foo' branch right now. I just ran git merge master . The only problem is that in foo there is a specific file that I wanted to save. Is there a way to revert it, but save all other changes from the merge wizard?

+43
git branch repository
Jan 19 '10 at 19:42
source share
2 answers

Try something like this:

 git checkout HEAD -- filename 

This will roll back your file. If you want to return to a specific commit, you can use a commit hash or add ^ N at the end of the HEAD keyword, for example. HEAD^2 .

+46
Jan 19 '10 at 19:52
source share

I'm not sure how to fix the problem from the current situation, but you can look at git merge -s ours . The docs are here .

Workflow will be

  • Create branch a from master
  • Make your own change in branch a , which you do not want to merge back into master
  • Check out master and git merge -s ours a
  • Check out a and continue to work and commit.

Now, when you merge with the master, the user changes in step 2 will be ignored.

0
Jan 19 '10 at 19:48
source share



All Articles