I have a branch A and master in a git repo.
In branch A I have done several additions, deletions. At some point, these changes were also merged in Master but we had to release master without these changes so we removed the file in master.
Now, when merging master into branch A, to get the last changes, Git obviously deletes the files since they have been deleted in master after the last changes.
What is the easiest way to keep branch A changes while merging back last Master changes?
What git does makes sense, it sounds like you agree with that. I'd let git do what it does and keep the default merge commit, then re-add the missing file in an extra commit:
$ git checkout master
$ git merge A # the file is gone
$ git checkout A -- file.txt
$ git add file.txt
$ git commit -m"Reintroduce file.txt, which was deleted for release"
I don't like modifying merge commits manually, rather let git do them, then fix afterwards. It causes less surprise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With