Git lesson 0: configure user.name and user.email

After installing Git, you will have to provide your name and email address. You will use the --global
flag to set a default Git user.name
and user.email
for all your projects. This can be overriden by --local
if ever you want to use a different username or email for a specific project.
git config --global user.name "Martin Heroux"
git config --global user.email heroux.martin@gmail.com
Create aliases
Most Git commands accept flags, which modify the behaviour of the command. For example, --global
was a flag to the config
command. Some of these flags are used so regularly that it can be handy to create a shortcut, also called an alias. This means that you can type the shortcut and git will understand that you actually mean the command and flags you specified when you created the alias. Aliases can save you lots of typing!
You will create 3 Git aliases that you will use as part of this tutorial. Once you become more familiar with Git, feel free to create your own. The syntax for creating git aliases is as follows:
git config --global alias.slog "log --oneline --topo-order --graph"
git config --global alias.st "status --short"
git config --global alias.diffc "diff --color-words"
After running these lines on the command line, you will be able to, for example, type git slog
to view the log of your git repository with Git commits on separate lines. When you type git slog
, git automatically replaces slog
by log --oneline --topo-order --graph
. Same goes for the other aliases we created. And don’t worry if you don’t understand what we mean by ‘repository’ or ‘commit’, this will become clear in the next lesson.
In order to view all the aliases you have created, type:
git config --get-regexp alias
In the next lesson you will learn how to initialize your first Git repository and verify the status of your repository.