Let's say I have branch send-stats, and I have couple of commits which I need to squash and merge to devel branch.
Follow these steps:
git checkout send-stats- switch to my branchgit rebase -i devel- rebase interactively relatively todevel, here we need to squash all commits to the first one- in vim:
:2,$s/pick/f/- relacespicks toffor every line except first one - indicates those commits as 'to squash' - save
- in vim:
git push -f upstream- push upstream to origin, changing historygit checkout devel- switch todevelgit pull- what if origin/devel changed? pull it!git checkout send-stats- back to my branch (this awkward moment you jump between branches for no good reason)git rebase origin/devel- put newly squashed commit on top of devel branchgit push -f- not sure if we need it, but let's rewrite the history once againgit checkout devel- I know, back theregit merge send-stats- finally!git push- uhhh, it was a long daygit push origin :send-stats- that's how we delete the branch in git :(- drink coke
In case of commiting all commits with history make sure you get extra commit of merging meaning there is no fast-forward: use key --no-ff