Git

Useful Defaults

Fast Forward Only: Avoid merge commits when possible by using the --fast-forward strategy for git pull. This can be set in your git config with:

git config --global merge.ff only

Enable Autocorrect: Allow git to autocorrect mistakes after a timeout. For example, running git commt or git psuh will automatically “do the right thing” after a specified timeout.

git config --global help.autocorrect 20

The unit of this config setting is tenths of a second, so a setting of 20 means that git will automatically run what it thinks the correct command is after 2 seconds. (See this post for a bit more detail.)

Tips

Pull with --autostash: If you frequently see errors when running git pull related to unstaged changes, you can have your working directory automatically stashed and re-applied using --autostash:

$ git pull
error: cannot pull with rebase: You have unstaged changes.
# 😥

$ git pull --autostash
Created autostash: 798c4a2
Current branch main is up to date.
Applied autostash.
# 😀

Longer Posts