Sunday, May 25, 2014

[Quick Note] Modifying Git Configurations in Ubuntu and Windows

OS : Ubuntu 13.10 or Windows 7

This is a brief post on how to change default configuration entries for Git.

There might be requirements that you need to change the default username where the commits get written to github, specially if you created a new github account, changed email etc.

Git uses global configuration file called .gitconfig in order to store the global credentials. To change the default user you can simply edit this file.

isha@thinkpad:~$ vim .gitconfig

For Windows this file can be found in file: git/etc/.config location.
I have set the following three properties here.

 1. username: github username of author.
 2. user email: github email address of user.
 3. credential helper: turn on the credential helper so that Git will save your password in memory for some time. By default Git will cache your password for 15 minutes. You can change this by changing --timeout property in the command.

[user]
        name = ishadil
        email = ishadil@github.com
[credential]
        helper = cache --timeout=3600  // i have changed timeout for 1 hour


Other option is doing this using the command prompt as below.

git config --global user.name "ishadil"

git config --global user.email "ishadil@github.com"

git config --global credential.helper 'cache --timeout=3600'

After that use git config --global --list command to verify whether the properties are reset correctly.

git config --global --list

In a similar manner there are lot more configuration entries that can be set into this file. For e.g. let's set a proxy url in to git .config file.

[http]
    proxy = proxy-test.abc.com:8080

No comments:

Post a Comment