You can set up global "git config" settings that apply to all git projects on your system. In this lesson, we review how the
./gitconfig file works. We then add our own git config settings: username, email, editor, and git aliases.
There are many other git config commands that can be used, but this lesson shows you pattern behind them all so you can view and edit your own settings.
[00:00] First, let's change directories to our user root. We can check to see if we already have a Git config file. In this case, we don't. Whether or not we already have a Git config file, we can use the Git config command with the global parameter to tell it to add a new setting to our Git config file.
[00:19] Let's add a new username, and we'll say Jane Doe here. If we output the contents of our Git config file, we could see that the username of Jane Doe has been added. When we use the Git config with a global param, it writes to the Git config file in our root directory.
[00:42] To write an email to our Git config, we'll say Git config with the global param, and we'll say user.email is going to be email@example.com. If we output our Git config file, we can see that an email has been added.
[00:58] To set our editor that Git will use to resolve conflicts and other operations, let's use Git config with the global param. We'll say core.editor is going to be Vim, in my case. Your editor may be different. If we output our Git config, we can see that our editor has been set.
[01:19] We can set aliases in our Git config by saying Git config with the global param. We say alias, and then the name of the alias. For example, let's create a log command that automatically creates a graph representation of our Git history.
[01:36] We'll say graph and then the command inside of the quotes here. We'll say log, we'll give it the graph param, and we'll tell it to just use one line at a time in our logs. If we look at our Git config file, we can see that an alias has been added.
[01:54] We can use that alias by saying Git and then the alias name, which for us was graph. Now, we're running that command. If you want to create a Git alias, the important pieces, going back to our command, are the graph piece can be replaced with any name that you want for an alias. Inside of your quotes, you have any Git command.
[02:16] If you ever want to see what's in your Git config file, you can always output the file like we did before. You can also use a built-in Git command, where you say Git config and then say list. It will give you a condensed list of all of the rules that you have in your Git config file.