Git Squash and rebase
Squashing and rebasing the commits is one of the important parts of Github. so here we will see how it works.
rebasing your branch with the master branch. suppose you are in your working branch
- commit all your files.
git checkout mastergit pull origin mastergit checkout your_branchgit rebase master
Squash your X commits.
git rebase -i head~X(where x is no.of commits)- a file will be opened in terminal edit that file.
- replace
pickwithfof all the commits except the first one. - save that file.
- your all commits will be squashed to the first one.
Rename your last commit.
git rebase -i HEAD~1- replace
pickwithr - save the file and a new file will be opened then update the name of that commit.