Home > Blockchain >  squash commits in git and remove "ugly" merge message
squash commits in git and remove "ugly" merge message

Time:01-21

I am trying to squash 2 commits and remove merge part, but have some problems.

I have branch main and featureBranch. In my terminal I do:

git checkout main
git merge --squash featureBranch
git push

But nothing really happens. I am in the project folder, I did pull and fetch so I have all the necessary data. How to do that. (VCS is bitbucket even though this shouldn't be important)

PS. I want to do the squash without using interactive rebase option (it is much more complicated that way, at least in my opinion)

CodePudding user response:

If you have already pushed to origin you will have to rewrite history with a force. If you want to squash commits before pushing you can do

git rebase -i HEAD~<num-commits-to-squash-from-head>

In the interactive page keep a "p" for pick on the commit you want to squash into and replace the command the for rest with "s". After saving this git will let you edit the commit message for the squashed commit

  • Related