Git Configuration

Initial Setup

The first thing you need to do after installing Git is to set your default details as follows:
git config --global "John Smith"
git config --global ""
These details will apply to every repository you have on your machine. However sometimes you need a different e-mail address for personal or work stuff, in which case change into that repository's directory and execute this:
git config ""
You can add a --local into the previous command, if you prefer. If you need to confirm this is working as expected then the following will return the e-mail address based on your current location:
git config
This is something you should really check before your first commit.


Typically git will combine the username and e-mail address to make the author, which following on from the example about would be "John Smith <>".

Other Setup

git config --global http.proxy http://hostname:port - essential when you are behind a proxy server, note that this works when your Git repo is on https

Ignoring Files

So, the easy way to ignore a file is to add it to your .gitignore file. Usually this will be in the root directory of the repository and contain a list of files, file extensions and directories to be ignored. You can add comments to the files by starting a line with a #, which is a good idea, and allows you to remember why you are ignoring some files. You can even commit your .gitignore file to Git, that way, everyone is ignoring the same files. This is all explained at Git - gitignore Documentation.

However when working on a Mac you will probably find you need to keep ignoring files like .DS_Store which will apply to every Git repository you use. However you may not want this in your .gitignore as others might not be on a Mac. In which case you can use a computer wide ignore file as follows:

  • Enter this: vi ~/.gitignore
  • Add a couple of lines as follows:
    # Mac Specific
  • Enter the following command: git config --global core.excludesfile ~/.gitignore
You might prefer to call the file .gitignore-global but that is just personal preference. Oh and note that all .DS_Store files are ignored in all directories, from a Git perspective. It is worth looking at github/gitignore: A collection of useful .gitignore templates for some good example files.