Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git branch diff into one new commit

Tags:

git

github

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?

like image 724
hhh Avatar asked Feb 14 '13 21:02

hhh


People also ask

Can two different branches refer to same commit in git?

Yes, two branches can point to the same commits.

What is rebase branch?

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.


1 Answers

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.

like image 91
qqx Avatar answered Oct 10 '22 17:10

qqx