So I know, I know, I need to get on with getting connected up to Github or VSTS, pull requests, etc. But I’m taking my time. I’m using Professional Git as my guide on this journey. So far I’ve found Brent’s explanations very easy to understand, and he is doing a great job of getting me started.
I want to start off by poking around the Git interface a little, and seeing how things work.
Git supports autocomplete, which is going to come in very handy for me. Here I’m working in the Git Bash shell. If you type git c and Tab once, nothing happens. That’s because you didn’t type enough to make the value unique. Tab again, and it shows you all the commands available.
Try typing git con and hit Tab. It will complete the command to git config, because the only match for con was config, hence you only had to Tab once.
Tab also works for attributes. Type git config –l and it will show you the options
Note: The Windows Git CMD prompt provides a similar, but not exact, experience with commands, but does not work with attributes.
LET’S TELL GIT WHO I AM
Git is apparently going to need my username and email so it can track who makes what changes. Makes sense. If you don’t set these values in your environment, Git will try and figure it out based on the logged in user. But I don’t want to do that. I want to set the values explicitly.
To set these values, you can run the following commands:
git config –global user.name <UserName>
git config –global email.name <EmailAddress>
If you want to see the values currently set for user.name and email.name, type git config –list.
Git is designed for you to use many different repositories. As such, there are three different levels, or scopes, where you can run commands:
System (specify using –system)
- The value applies to all repositories on a given system, unless overridden at a lower level, and apply regardless of the particular user.
Global (specify using –global)
- Value applies to all repositories for a particular user, unless overridden at the local level. This is the most common level for users to work with. While I could have set my User Name and Email address at the local level, then I would have had to do it for each repository I create.
Local (specify using –local)
- Value applies only in the context of a single repository. This is also the default scope if you do not specify a scope in the command.
As you can guess, the order Git looks for things is: Local è Global è System.
The screenshot below shows the git config –list commands run at different scoping levels. It allows you to see what values exist at what levels.