Git Fuck It: Alias to delete all the stupid shit you did last night. Gets you back to a clean repository.
alias git-fuckit='git clean -d -x -f; git reset --hard'
Here’s how it works:
- -d : Removes untracked directories
- -x : Ignore rules in the .gitignore file
- -f : Force it to happen
- reset –hard : Discard any tracked files in the repository
Late night hacking goes like this: Usually around 1am I’ll get some bat-shit-crazy idea. Something like, “This class sucks. I should rewrite the whole thing!” So I start hacking at it.
I slaughter everything! Tests? Documentation? Forget it. Nothing is safe. By the time I’m done it’s 3am, I’m completely exhausted, delirious, and I’ve managed to touch every file in the repository. That’s when I close my laptop and go to sleep.
When I wake up the next morning, I’ll look at this complete train wreck I made and go, “Oh. My. God. What have I done?” Everything is broken! Tests are failing, Rails won’t start, and none of it makes any sense.
So I made “git fuck it.” It erases everything I did and gets back to the last good commit. It’s inelegant and unforgiving but it cures all the coding sins from the night before. The code is made whole again.