GIT

Config

Alias

alias.br=branch
alias.co=checkout
alias.d=diff --word-diff=color
alias.g0=log --oneline --graph --all --decorate --full-history --submodule
alias.g=log --graph --full-history --submodule --format="%C(auto)%h %Cgreen%<(7,trunc)%cN%C(auto)%d %s"
alias.ga=log --graph --all --full-history --submodule --format="%C(auto)%h %Cgreen%<(7,trunc)%cN%C(auto)%d %s"
alias.gv=log --graph --all --full-history --submodule --format="%C(auto)%h %t %Cgreen%<(7,trunc)%cN %Cred%ad%C(auto)%d %s" --date=format-local:"%Y-%m-%d %H:%M:%S"
alias.s=status -sb
alias.cat=cat-file -p
alias.type=cat-file -t
alias.ss=!git s && git submodule foreach 'git s'
alias.sd=!git d && git submodule foreach 'git d'

Tips/Trick

Changing line endings in repository

Based on StackOverflow Answer.

# change settings
git config --local --replace-all core.autocrlf true

# clear Index
git rm --cached -r .

# re-add files
git add .

# commit
git commit -m "crlf fix"

Ignore changes of tracked file

# ignore
git update-index --assume-changed <file>

# unignore
git update-index --no-assume-changed <file>

# list
git ls-files -v|grep '^h'

Transfer

Patch

cd from
git format-patch --stdout master^ > .../file.patch

cd to
git apply --check .../file.patch
git am .../file.patch

Bundle

cd from
git bundle create .../file master~3..master 
git ls-remote .../file

cd to
git bundle verify .../file
git pull .../file

Putty/Pageant

GIT_SSH='C:\Program Files\Putty\PLINK.EXE'

Starting KDiff3 as Merge Tool on the Git GUI

This will register KDiff3 as an external Tool on the GUI.

git config --global --replace-all merge.tool kdiff3
git config --global --replace-all mergetool.kdiff3.cmd '"C:\\Program Files\\KDiff3\\kdiff3" $BASE $LOCAL $REMOTE -o $MERGED'
git config --global --replace-all guitool.KDiff3.cmd 'git mergetool'

Uncompress file (Windows)

openssl zlib -d < {file}

Update branch without changing to it

git fetch <remote> <source>:<destination>

This only works with fast-forward merges [1].
Example:
git fetch origin master:master

git
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.