Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

git cherry pick and hightlight all changes with (conflict) markers

I want to add changes from a specific commit using git cherry-pick commitId.

However, it would be very useful to mark all changes (for example with conflict markers) so I can accept them manually.

As a novice I failed to find a solution online. I stumbled upon -no-ff option, hoping this does not automatically make changes, but it did.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any help appreciated!

>Solution :

To do a "slowed down" cherry-pick and review each change individually, you can use the --no-commit flag (or -n in short form) and use interactive add:

git cherry-pick -n <commitId>

# at this point, all changes are present but nothing commited yet

git reset
git add -p

It will then cycle through each chunk of change (even non-conflicts), for you to decide what you need (take, leave, edit, etc.)

(You could also, instead of resetting/re-adding at the end, just git reset -p and interactively unstage changes you don’t want, but the logic might feel a bit backwards for some people, feel free to use it if you prefer)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading