A collection of useful git commands, because I'm lazy and can't be bothered to remember off by heart
scenario: free up space on your machine. delete anything that's been merged, no need to have it any more.
git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
scenario: you worked on something at 2am on a Saturday morning. You don't want your colleagues to think you're a madman. Change it before standup on Monday morning.
git commit --amend --date="now"
scenario: You just need to force git to accept a commit without editing files. Useful for CI
git commit --allow-empty -m "This will trigger a build"
scenario: You just need to push some files, but there isn't any significant thing to say e.g removeing console.log commands
git commit --allow-empty-message -m ""
scenario: useful when you need to kick off another build
git commit --amend --no-edit -m "nothing changed. need to trigger something"
scenario: you have made a whole bunch of changes and they all deserve to be in seperate commits
git add -p
scenario: you made a bunch of changes, you have some messed up history, you want to organise your shit
git reset --soft <commit>
scenario: you commit a bunch of stuff, pushed to github, but now you need to back out the changes, and preserve git history
git revert -m 1 <commit id>