Git is one of the most common tools for developers, but we often learn just enough to get the work done. Below are some optional configurations for git you might not have encountered.
Git uses this information to say who committed what. After all, software is often a team effort. By default, git will look for this information by asking your system and choose a default, but if you want full control, here is how you set this information.
$ git config --global user.name "My Name" $ git config --global user.email "email@example.com"
--global flags, meaning these settings will be applied system-wide, as opposed to the user level.
Some git commands can feel long and tedious at times, why not make some aliases? Aliases are nicknames for shell commands. For example, we can tell git that when we run
git st, we mean
git status. Here are some reasonable ones from the git docs.
$ git config --global alias.st status $ git config --global alias.co checkout $ git config --global alias.br branch $ git config --global alias.ci commit
Aliases behave the same way as the full command, meaning you can provide them flags and arguments as usual.
Are you always misspelling your git commands? Irritating, I know. Git can take help by guessing what you probably meant and doing it. Git auto-correct setting lets you choose how much time it waits before executing on its assumption.
$ git config --global help.autoCorrect 30
The argument we provided above is an integer representing tenths of seconds.
30 means git waits for 3 seconds. If git got it wrong, cancel the command with
CTRL + C before the time is up and try again.
I hope you learned something new! Be careful with git auto-correct, and thanks for reading!
Photo by Pradipna Lodh from Pexels