So let's say I have a main branch, we'll call 'master'. I've made a branch, called 'new-feature'. I've made a ton of commits in this branch so I can go back in time, but I've done quite a bit of back and forth on while developing the feature so the commit log is pretty messy.
If I were to look at git diff master..new-feature for example.
If I wanted to create just one new fresh commit on 'master' that includes all the changes in between the two branches, what's the most efficient way to do that?
Yes, two branches can point to the same commits.
From a content perspective, rebasing is changing the base of your branch from one commit to another making it appear as if you'd created your branch from a different commit. Internally, Git accomplishes this by creating new commits and applying them to the specified base.
git checkout master
git merge --squash new-feature
git commit
The commit message will start out showing the entire list of commits being merged/squashed, but you can of course edit that to be whatever you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With