A list of stupid Git tricks so I don't have to keep remembering them.
Oops, I messed up.
This will remove anything staged but not committed:
git reset --hard
If you really messed up, this will remove all untracked files/directories as well:
git clean -df .
If you already committed but haven't pushed yet, this will remove the latest commit, but keep the changes in your local working directory:
git reset --soft HEAD~1
If you already committed and pushed:
git revert [commithash]
Git is giving me permission denied errors on settings.php. What now?
sudo git checkout -- sites/default
chmod ug+w sites/default
I have an anonymous clone, but I have commit access to the project. How do I switch to my authenticated URL?
So you were originally just a mere end-user of a project, but then you filed one too many patches and went and got made a maintainer, eh? ;) Don't panic, here's a simple command to bless your clone with commit access:
git remote set-url origin firstname.lastname@example.org:sandbox/greggles/1481160.git
/HT @wereHamster in #git
I have clumsy fingers and keep mis-typing commands like "git pusj"
There's a config option for that!
git config --global help.autocorrect 3
Will give output like this:
$ git pusj
WARNING: You called a Git command named 'pusj', which does not exist.
Continuing under the assumption that you meant 'push'
in 0.3 seconds automatically...
/HT @cyberswat in #drupal-contribute