SJCNet is the home of architect/developer/techie, Simon Coope.

GIT - Basic Set-up

There are a few config steps I always have to perform when I set-up GIT on a new PC, but these are the steps that I perform so infrequently that I forget them! So I'm going to write them out here for a reference for myself and others!

Config Locations

First though, it's important to understand the basics of the GIT config system. GIT stores configuration in three places:

System - This configuration contains values for every user of the system and all of the repositories used on the system. On Windows it's usually stored at C:\ProgramData\Git\config. The contents of this file can be read from the command line using:

$ git config --list --system

Global - This configuration is specific to your user. It's stored in %UserProfile%.gitconfig and can be accessed from the command line using the following:

$ git config --list --global

Local - The local GIT repository you're working on always has it's own .gitconfig file. This is usually stored in the root of the project in the .git folder and you can view the contents using the following command:

$ git config --list --local

Finally, you can view the amalgamated configuration for your current instance (which is made up of the system, global and local configuration) by running this command:

$ git config --list

Config Settings

The following are some of the more common configuration settings you'll want to make for GIT when setting it up for the first time.


Your username is used to associate a commit with an identity. So set your username use the following command:

$ git config --global "Simon Coope"

Here I set this at the global level because that configuration level is specific to my user.


This is linked to the username in that it's used as part of your identity when creating a commit. To set your email you use:

$ git config --global


Now to the more interesting configuration settings. GIT has an internal diff tool which it will use by default if you don't specify your merge and diff tools in the configuration. However, I find this tool a little tricky to use, so I always prefer to use KDiff3.

To set-up KDiff3 as my merge tool, I have to run the following commands:

$ git config --global merge.tool kdiff3
$ git config --global mergetool.kdiff3.cmd '"C:\\Program Files\\KDiff3\\kdiff3.exe" $BASE $LOCAL $REMOTE -o $MERGED'

This adds the following entries into your global (user specific) config file:

	tool = kdiff3
[mergetool "kdiff3"]
	cmd = \"C:\\\\Program Files\\\\KDiff3\\\\kdiff3.exe\" $BASE $LOCAL $REMOTE -o $MERGED

Now when you want to run a merge just run the command git mergetool.


The diff tool is used to show the differences between files/commits. To set to be KDiff3 run the following commands:

$ git config --global diff.tool kdiff3
$ git config --global difftool.kdiff3.cmd '"C:\\Program Files\\KDiff3\\kdiff3.exe" $BASE $LOCAL $REMOTE

This adds the following entries into your global config file:

	tool = kdiff3
[difftool "kdiff3"]
	cmd = \"C:\\\\Program Files\\\\KDiff3\\\\kdiff3.exe\" $BASE $LOCAL $REMOTE

Now if we want to run a diff between the last two commits, we can run $ git difftool HEAD^ HEAD


This was a really quick post to document the steps I go through every time I set-up GIT again on a new machine. Hope it helps someone as much as it will help me!

Author image
About Simon Coope
Sydney, Australia Website
Experienced developer/consultant. Loves all things development, technology, gadgets, football and running.