My Git Commit Process – squash, rebase, commit

SQUASH ALL THE COMMITS TO YOUR FEATURE BRANCH INTO ONE COMMIT
git rebase -i HEAD~4 (where 4 is the amount of commits you wish to squash)
ONCE ALL COMMITS ARE SQUASHED INTO ONE, ENSURE TO ORIGINAL BRANCH IS UP TO DATE
git checkout master
git pull origin master
NOW THAT ORIGINAL IS UP TO DATE, REBASE
git checkout myFeatureBranch
git rebase – i master
DELETE REMOTE VERSION OF FEATURE BRANCH
git push origin :myFeatureBranch
PUSH TO REMOTE REPO
git push origin myFeatureBranch

Advertisements

Git commands I frequently use but never remember…

  • Delete a remote git branch but keep it locally:

git push origin :branchname

  • Delete a local git branch but keep it remotely:

git branch -d branchname

  • Rename a local branch:

git branch -m

  • Rename current branch

git branch -m

  • Delete the previous remote commit and revert to the second to last one

git reset –hard