tags:

views:

8586

answers:

14

Hi,

I am looking to pimp up my ~/.gitconfig to make it really beautiful and take maximum advantage of capabilities git can offer. My current ~/.gitconfig is below, what more would you add? Have some nice ~/.gitconfig you want to share? Any recommendations for merge and diff tools in linux? Post away and let's build a nice ~/.gitconfig

[user]
        name = Rajkumar
        email = [email protected]

[color]
        diff = auto
        status = auto
        branch = auto
        interactive = auto
        ui = true
        pager = true

[color "branch"]
        current = yellow reverse
        local = yellow
        remote = green

[color "diff"]
        meta = yellow bold
        frag = magenta bold
        old = red bold
        new = green bold

[color "status"]
        added = yellow
        changed = green
        untracked = cyan

[core]
        pager = less -FRSX
        whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol

[alias]
        co = checkout

Thanks!

raj

+9  A: 
[alias] 
    st = status
    ci = commit
    co = checkout
    w = whatchanged

[diff]  
    renamelimit = 0

[color] 
    diff = auto
    interactive = auto
    status = auto
    branch = auto
ididak
What does the renamelimit do? I've looked at it in git docs but I still don't get it.
drozzy
diff.renameLimit: The number of files to consider when performing the copy/rename detection; equivalent to the git diff option -l. http://www.kernel.org/pub/software/scm/git/docs/git-config.html
mmrobins
`st = status ci = commit co = checkout w = whatchanged` - ewwwww
BlueRaja - Danny Pflughoeft
+10  A: 

Great idea! Actually I have little to offer over these configs, except maybe this:

[core]
  excludesfile = /Users/mat/.gitignore

Make sure you use a complete path (i.e. not ~) for your global ignore file. This is especially useful when you create git repos extremely often, it just removes the need to create the same git ignores over and over.

Of course when other people are going to work on the project, you'll want to create a proper ignore file for the project :-)

webmat
Thanks dude. That was helpful!
johncblandii
Git 1.6.5.5+ can use `~/whatever` in `core.excludesfile` (and some other configuration variables).
Chris Johnsen
+9  A: 
[apply]
  whitespace = fix

This will both warn you about some whitespace errors (such as trailing whitespace), as well as try and fix them for you.

Scotty Allen
+9  A: 

When using github.com this might be useful

[github]
    user = github username
    token = github API token
x-way
+4  A: 

Figuring out how to add a GUI external diff/merge tool was not easy so I'll include that bit from my ~/.gitconfig

Writing git-diff-driver.sh is left as an exercise for the reader :)

[diff]
    external = "/Users/mark/bin/git-diff-driver.sh"
[merge]
    tool = araxismerge
[mergetool "araxismerge"]
    cmd = "/usr/local/bin/compare -3 -merge -wait $LOCAL $BASE $REMOTE $MERGED"
    path = /usr/local/bin/
Mark Thalman
This is a killer-feature. --- opendiff for Mac users.
Masi
What I don't like about FileMerge is you can't edit the file in the diff view. That is one of the reasons I bought Araxis Merge.
Mark Thalman
+4  A: 
[user]
    name = prtksxna
    email = [email protected]

[branch "master"]
    remote = origin
    merge = refs/heads/master

[color]
    pager = true
    ui = true
    status = auto
    branch = auto

[alias]
    st = status
    ci = commit
    br = branch
    co = checkout
    df = diff
    lg = log
    pom = push origin master
[color "status"]
       added = yellow
       changed = green
       untracked = cyan
+2  A: 

Here is also a pretty nifty configuration file: http://www.jukie.net/~bart/conf/gitconfig.

The file is linked from http://www.jukie.net/~bart/blog/pimping-out-git-log.

Olivier
+1  A: 

A couple more .gitconfig options I've found useful.

[diff]
    renames = copy # makes the diff much shorter when moving or copying files
[commit]
    template = ~/work/developer/util_src/git/.gitcommittemplate

renames = copy is like passing the -C option to 'git diff', which detects when you move or copies files and only shows you the changes between the original instead of the whole file.

Where I work we like to have somewhat consistent commit messages that indicate the ticket number associated with the commit, who paired on and/or who reviewed the commit, so having a template is a good way to remind people to fill that in. The template comes up automatically if you commit without the -m option.

mmrobins
+1  A: 

Mine's not that exciting, but I do have some useful aliases:

[apply]
    whitespace = nowarn
[color]
    branch = auto
    diff = auto
    interactive = auto
    status = auto
[interactive]
    singlekey = true
[merge]
    tool = opendiff
[alias]
    br = branch
    ci = commit
    co = checkout
    sb = show-branch
    st = status
    ds = !git --no-pager diff --stat -M -w
    changes = log --oneline --reverse
    # fork = !sh -c 'git rev-list --boundary $1...$2 | grep ^- | cut -c2-'
    graph = log --graph --oneline --decorate
    info = config --list
    pop = !git stash apply && git stash clear
    staged = diff --cached
    summary = log --oneline
    tags = tag -n1 -l
mipadi
A: 
[core]
    excludesfile = ~/.gitignore

[alias]
    lg = log --graph --pretty=oneline --abbrev-commit

and more.

Kana Natsuno
+3  A: 
#
# This is the config file, and
# a '#' or ';' character indicates
# a comment
#

[color]
    ui = auto

[user]
    name = xxxxxxxxxxxxxxxxx
    email = xxxxxxxxxxxxxxxx

[branch]
    autosetupmerge = true

[apply]
    whitespace = nowarn

[alias]
    st = status
    au = add -u .
    ci = commit
    ciam = commit --amend
    br = branch
    co = checkout
    df = diff
    lg = log
    lp = log -p
    lt = log --topo-order
    gl = log --graph
    # glp = log --graph --pretty=oneline --abbrev-commit
    glt = log --pretty=format:'%h : %s' --topo-order --graph
    rl = reflog
    sb = show-branch
    brm = branch --merged
    brnm = branch --no-merged
    rnc = revert --no-commit
    com = checkout master 
    hard = reset --hard
    me = merge --no-commit --no-ff
    ls = ls-files
    pu = pull
    cp = cherry-pick
    cpnx = cherry-pick --no-commit -x
orange80
+1  A: 
[core]
    editor = gvim -f
    pager = cat
[alias] 
    amend = commit --amend
    co = checkout
    d = diff
    dc = diff --cached
    ds = diff --stat
    dsc = diff --stat --cached
    l = log --pretty='tformat:%h %an (%ar): %s'
    ly = log --pretty='tformat:%h %an (%ar): %s' --since=yesterday
    s = status
    r = show --raw
    rank = shortlog -sn --no-merges
    w = whatchanged --reverse
Amadeus
+2  A: 

some aliases i have

    # thanks to zach wily, this is for pushing reviews to gerrit
    push-change = "!bash -c ' \
        local_ref=$(git symbolic-ref HEAD); \
        local_name=${local_ref##refs/heads/}; \
        remote=$(git config branch.\"$local_name\".remote || echo origin); \
        remote_ref=$(git config branch.\"$local_name\".merge); \
        remote_name=${remote_ref##refs/heads/}; \
        remote_review_ref=\"refs/for/$remote_name\"; \
        r=\"\"; \
        if [[ $0 != \"\" && $0 != \"bash\" ]]; then r=\"--reviewer=$0\"; fi; \
        if [[ $1 != \"\" ]]; then r=\"$r --reviewer=$1\"; fi; \
        if [[ $2 != \"\" ]]; then r=\"$r --reviewer=$2\"; fi; \
        if [[ $3 != \"\" ]]; then r=\"$r --reviewer=$3\"; fi; \
        if [[ $4 != \"\" ]]; then r=\"$r --reviewer=$4\"; fi; \
        git push --receive-pack=\"gerrit receive-pack $r\" $remote HEAD:$remote_review_ref'"

    # thanks to cody cutrer
    cherry-pick-merge = "!bash -c 'git cherry-pick -n -m 1 $0 && \
        git log -1 --pretty=%P $0 | cut -b 42- > .git/MERGE_HEAD && \
        git commit -v'"

    # other useful things
    remote-ref = "!bash -c ' \
        local_ref=$(git symbolic-ref HEAD); \
        local_name=${local_ref##refs/heads/}; \
        remote=$(git config branch.\"#local_name\".remote || echo origin); \
        remote_ref=$(git config branch.\"$local_name\".merge); \
        remote_name=${remote_ref##refs/heads/}; \
        echo remotes/$remote/$remote_name'"
    rebase-recent = !git rebase -i $(git remote-ref)
jtolds
+2  A: 
[rerere]
    enabled = true
[alias]
    # https://git.wiki.kernel.org/index.php/Aliases
    co = checkout
    st = status
    # usage example: git w -n5
    w = whatchanged
    # add all changed (but not new) files to stage (index):
    au = add -u
    # show conflicting merge in gitk:
    gitkconflict = !gitk --left-right HEAD...MERGE_HEAD
    # prune all tracking local branches that have been removed from remote:
    prune-all = !git remote | xargs -n 1 git remote prune
    # show full history in gitk (including "deleted" branches and stashes)
    history-all = !gitk --all $( git fsck | awk '/dangling commit/ {print $3}' )
    # show list of contributors in descending order by number of commits
    rank = shortlog -sn --no-merges
    # given a string for an author, try to figure out full name and email:
    whois = "!sh -c 'git log -i -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1\"' -"
    # given any git object, try to show it briefly
    whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
    # Search for a given string in all patches and print commit messages
    # example: search for any commit that adds or removes string "foobar"
    #     git searchcommits foobar
    # example: search commits for string "foobar" in directory src/lib
    #     git searchcommits foobar src/lib
    # example: search commits for "foobar", print full diff of commit with 1 line context
    #     git searchcommits foobar --pickaxe-all -U1 src/lib
    searchcommits = "!f() { query=\"$1\"; shift; git log -S\"$query\" \"$@\"; }; f \"$@\""
Mikko Rantalainen