Saturday, March 29, 2014

Git Config Commands

I have been doing a bunch of work with Git lately.  I wanted to do a post about some commands I don’t want to forget.

Who are you?
git config --global user.name '<name goes here>'
git config --global user.email '<email address here>’

Turn off https verification
We are using Stash and its using a self signed certificate.  This command allows us to access the Stash repositories over HTTPS.

git config --global http.sslVerify false

Make notepadd++ your editor (no more vim)
I am not a VIM kinda guy so this was a huge help when using things like rebase.

git config --global core.editor '"C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -nosession –noPlugin'

Set Visual Studio 2013 as your diff tool
git config --global difftool.prompt true
git config --global difftool.vs2013.cmd '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe" "$LOCAL" "$REMOTE" //t'
git config --global difftool.vs2013.keepbackup false
git config --global difftool.vs2013.trustexistcode true
git config --global diff.tool vs2013

Set Visual Studio 2013 as your merge tool
git config --global mergetool.prompt true
git config --global mergetool.vs2013.cmd '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe" "$REMOTE" "$LOCAL" "$BASE" "$MERGED" //m'
git config --global mergetool.vs2013.keepbackup false
git config --global mergetool.vs2013.trustexistcode true
git config --global merge.tool vs2013

Log Alias
This alias I find really useful. I got this from one of my co-workers.  Here is a link to where it came form (source).

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

4 comments:

  1. This is great info but I keep getting "usage: git config [options]" when I try to set mergetool.vs2013.cmd. I am pretty sure that it has something to do with the quotes. I have spent a couple of hours fooling with different quoting schemes and reading other posts. Can you help?

    ReplyDelete
    Replies
    1. Ryan, is this still an issue? I was able to copy and paste these commands into a coworkers bash console the other day with no issues.

      Delete
  2. In order to work from a Powershell window, that line needs to be changed to:
    git config --global difftool.vs2013.cmd 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsDiffMerge.exe' "$LOCAL" "$REMOTE" //t

    ReplyDelete