There is no ready-made solution, but you can create an alias.
You can use:
git checkout HEAD -- <list of files to keep as HEAD>
to indicate that you want to save the specified files as they were in HEAD.
To get a list of remaining conflicts, you can use:
git diff --name-only --diff-filter=U
Then combining it as an alias gives:
alias gitkeeprest="for file in $(git diff --name-only --diff-filter=U); do git checkout HEAD -- $file; done"
With this, you would:
- Run the merge as usual.
- Allow the parts that interest you by adding them to the index.
- Put the remainder back as version
HEADby running gitkeeprest.
source
share