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

Merge git head onto previous branch

enter image description here

I have a git history that looks like this. Is it possible (and how would I) to merge the changes made in commit 5 (in unrelated files than commits 3 and 4) onto commit 2?

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

>Solution :

You need to:

  1. Create a branch off of Commit 2
  2. Cherry-pick Commit 5 into that new branch

If the hash for Commit 2 is a84212677 and the hash for Commit 5 is 2677a8421, then you’d do the following:

> git co a84212677
> git co -b newbranch
> git cherry-pick 2677a8421

Your Git repo would then look like this:

enter image description here

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