Sunday, September 6, 2015

Git Setup and Configuration

Configuring git for KDiff3
Add to .gitconfig (located C:\Users\Tim):

[diff]
    tool = kdiff3
[difftool]
    prompt = false
[difftool "kdiff3"]
    path = C:/Program Files/KDiff3/kdiff3.exe
    trustexitcode = true
[merge]
    tool = kdiff3
[mergetool "kdiff3"]
    path = C:/Program Files/KDiff3/kdiff3.exe
    keepbackup = false
    trustexitcode = true

then run it using >git difftool .\folder\Web.config
yes, using quotes to deal with the spaces in program files in .gitconfig file screws it up. Don't use quotes.

Using Console2
Scott Hanselman's blog post
I put a copy of the Console config file in SpiderOak under Dev/Git.

Powershell Execution Policy
Stackoverflow
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force


Making Powershell Readable
add to .gitconfig
[color]
    ui = true
[color "status"]
    changed = red bold reverse
    untracked = red bold reverse
    added = green bold
[color "branch"]
    current = green bold
(see copy of config file in SpiderOak)

Credential Caching
Avoid having to enter password
http://gitcredentialstore.codeplex.com/ (just install it, and it will prompt you once, then you're good)

Links
Getting set up in a new environment (git w/ PShell, PsGet, Posh-Git)
Must-have git aliases

[user]
 email = ttonnesen@gmail.com
 name = Tim


My aliases (not all work):

[alias]
s = status
c = commit -m
a = add
co = checkout
br = branch
sh = stash
dt = difftool
pb = push origin

# short log
logsimp = log --oneline --decorate
logSimpFiles = log --pretty=format:"%h%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decorate --numstat
logSimpDates = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decorate --date=short
logSimpAge = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decorate --date=relative

comp = difftool --dir-diff
#DoesntWork: compcommits = "!f() { git difftool "$1"^.."$1"; }; f"
# Same as compare-by-changeset but shows all files in directory. For ex: git lsf (shows commit changeset numbers) then git dcd 85a7f8b
#ProbDoesntWork: compare-by-changeset-directories  = "!f() { git difftool --dir-diff "$1"^.."$1"; }; f"

# list aliases to console
list-aliases = "!git config -l | grep alias | cut -c 7-"

# git stash show -p 'stash@{0}' shows tracked files that were stashed, but not untracked, the &&'d command shows untracked
stash0-show = !git stash show -p 'stash@{0}' && git ls-tree -r 'stash@{0}^3'
stash1-show = !git stash show -p 'stash@{1}' && git ls-tree -r 'stash@{1}^3'