Merging remote files from branch to master

I have branch A and master in a git repository.

On branch A, I made some additions, deletions. At some point, these changes were merged into Master as well, but we had to free the master without these changes, so we deleted the file in master.

Now, when merging master into branch A to get the latest changes, git obviously deletes the files as they were deleted in master after the last changes.

What's the easiest way to keep the changes on branch A when you merge the last change in master?

+3


source to share


2 answers


Which git

makes sense, you seem to agree with that. I would let you git

do what it does and keep the default commit and then re-add the missing file to the additional 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 that merge changes are done manually, but let them git

do them and then commit afterwards. This is less surprising.

+2


source


I would go ahead and merge the master in A, and then cherry-pick the commits that were reverted to A. So let's say you added the files that were added in commit abc123; and on A just do git cherry-pick abc123

. Repeat for all commits that were reverted or if they are a continuous list of commits, you can specify a range for cherry picking, for example. git cherry-pick 123..xyz

...



0


source







All Articles