How can you merge two branches in git, retaining necessary files from a branch?
When merging two branches, if a file was deleted in one branch and not in an
Casey's example didn't work for my case - I couldn't checkout test.txt
from master
, because it was no longer in that branch:
$ git checkout master test.txt
error: pathspec 'test.txt' did not match any file(s) known to git.
Happily I could pull the file out of branchA
's own HEAD
:
$ git checkout branchA
$ git merge --no-commit master
$ git checkout HEAD test.txt
$ git add test.txt
$ git commit