What I learned today...
Hello,
Today, I learned how to squash my commits from my feature branch before merging to main.
I was working in a feature branch for couple of days and I had made a lot of commits, but I wanted to squash all of my feature branch commits to one commit, to keep my main branch clean.
git rev-list main..feature | wc -l
git rebase -i HEAD~n
Then replace "pick" with "squash" for all commits except the first one and save the file.
On the new editor which will come up, delete all the commit messages there, write a new one and save the it. This will be the only commit message of your feature branch.
Then you can proceed with the merge of the featuer branch to main.
Please leave a comment if you have a better solution.
Bye :)
Top comments (0)