Reputation: 3095
I'm having a hard time trying to squash these excessive commits.
When I run git log --pretty=oneline
, the following items appear in the order below:
e44e012 Merge branch 'branch A' of https://github.com/ into branch A
4176991 Commit D
767583f Commit C
f5a4c21 Commit B
83bb8e1 Commit A
I want to squash these into one commit and get rid of the commit merge. When I run git rebase -i HEAD~2
, commits A-D appear, but the commit merge doesn't show up. Any idea why? When I try running git rebase -i HEAD~5
, I get commits A-D to appear along with some other commits, but the merge commit still doesn't show up as an option to squash.
* e44e012 Merge branch 'Branch A' of https://github.com/ into Branch A
|\
| * 767583f Commit C
| * f5a4c21 Commit B
| * 83bb8e1 Commit A
* | 4176991 Commit D
|/
Upvotes: 1
Views: 107
Reputation: 521103
Typing git rebase -i HEAD~5
should show you a list like the following:
pick 83bb8e1 Commit A
pick f5a4c21 Commit B
pick 767583f Commit C
pick 4176991 Commit D
pick e44e012 Merge branch 'branch A' of https://github.com/ into branch A
Note carefully that the oldest commit will appear at the top of the list, which is the reverse order from what git log
shows you.
If you want to squash the merge commit, along with commits B through D into commit A, then change the file to look like this:
pick 83bb8e1 Commit A
squash f5a4c21 Commit B
squash 767583f Commit C
squash 4176991 Commit D
squash e44e012 Merge branch 'branch A' of https://github.com/ into branch A
Save the file, close it, and then type git rebase --continue
to finish the rebase.
Upvotes: 1