My initial git settings for any repository

This is my cheat sheet for the settings I use for my git-repositories (list to be edited continuously):

Global settings:

git config –global user.name Martin Carpella
git config –global user.email xxx@yyy.invalid
git config –global color.ui auto

Per-repository settings:

git config core.autocrlf true
git config core.safecrlf true

Per-repository .gitignore for Visual Studio/C# projects:

bin
obj
*.user
*.suo
Thumbs.db

5 thoughts on “My initial git settings for any repository”

  1. Thanks, I’m just getting started with git and am planning to use it for some pre-existing projects, this helps. One question: why set the crlf stuff on a repository-only basis? In other words, when would you NOT want to use it? cheers & happy new year!!

  2. Another question: for Visual studio projects, what do you use as your ignore options? What files can you safely not include in the repository if you just want to generate them later by building with visual studio? I’m mostly using VC++ as a language, if that makes any difference.

  3. Hi,

    I do it on a per-repository basis because I have some projects where I cannot set core.safecrlf, for example projects where I use auto-generated ressource files in Visual Studio (they are generated with LF only).

    My default .gitignore for Visual C# projects is:
    bin
    obj
    *.user
    *.suo
    *.ncb
    Thumbs.db

    (Where *.ncb is for projects including C++ projects). Sorry, I primarily develop C# at the moment, therefore I have no set for real C++ projects and solutions at the moment.

    Hope this helps!

    Best regards,
    Martin

  4. Stuff from my config:

    to get some nice colorized output:
    git config –global color.status auto
    git config –global color.diff auto
    git config –global color.branch auto

    Add all changed, but not already staged files, to and remove all deleted files from the index:
    git config –global alias.addrm ‘!addremove() { git add -u . ; git add . ; }; addremove’

    Some aliases I use all the time:
    git config –global alias.pa ‘add –patch’
    git config –global alias.ia ‘add –interactive’
    git config –global alias.staged ‘diff –cached’ (Shows all staged changes)

    Other useful aliases:

    Undo the last commit:
    git config –global alias.undo ‘reset –hard HEAD@{1}’

    Retrack a branch to a different remote branch, see http://gist.github.com/29095:
    git config –global alias.retrack ‘!retrack() { git config “branch.$1.remote” $(dirname “$2”); git config “branch.$1.merge” “refs/heads/$(basename “$2″)”; }; retrack’

    Useful command you may not already know:
    git whatchanged: Shows a log + differences that each commit introduce
    git stash (|list|apply|clear|pop): Allows you to stash away changes in your current working directory for later. See manpage for more info.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.