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

How do I get diffs from two branches as a single commit and make it a new branch?

I have two branches called develop and feature, they both have lots of commits. Is there a way that I can make a branch called diff that it’s based on develop and has a single commit that makes contents of develop looks exactly like feature?

Basically diff and feature has the same content but it has a single commit that turns develop looks like feature.

  • Before
feature - B - D - F - G
             /
develop A - C - E
  • After
feature - B - D - F - G
             /
develop A - C - E - - -
                        \
diff                     H

G and H has same content so I can get rid of feature completely

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 :

git checkout -b diff feature
git reset --soft develop
git commit

or

git checkout -b diff develop
git read-tree -um feature
git commit

will do it.

Are you aware that what you’re asking for will also revert the changes in E?

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