How to squash commits in one branch?

Viewed 16774

I made a branch of trunk and been submitting/committing lots of changes. Every so often I would update the branch by merging from trunk (eg. 20 commits, then a merge-update, 20 more commits then a merge-update, etc).

Now I would like to squash everything in my branch. How can I do this (using either Git Extensions or console)?

I tried typing:

git rebase -i HEAD~200

but I don't know how many commits to squash. I tried counting the commits in Git Extensions but it's hard to see since it shows a mixture of everything from branch commits and trunk commits. The menu "Show current branch only" doesn't help.

3 Answers

This code will rebase in interactive mode your current branch commits and it will put rebased commits on top of master

git rebase -i HEAD~$(git rev-list --count origin/master..) && git pull --rebase origin master
Related