Skip to content

Instantly share code, notes, and snippets.

@jboehler
Last active June 5, 2020 04:31
Show Gist options
  • Save jboehler/4984054 to your computer and use it in GitHub Desktop.
Save jboehler/4984054 to your computer and use it in GitHub Desktop.

Git Installieren

Am einfachsten installiert man Git über Homebrew.

brew install git

Zusätzlich empfiehlt es sich bash-completion zu installieren um die komfortable Autocompletion Funktionalität in Git zu erhalten.

brew install git bash-completion

Um bash-complition zu aktivieren muss das .bash_profile noch ergänzt werden.

vi ~/.bash_profile

Folgende Zeilen müssen hinzugefügt werden:

if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi

Konfigurieren

Benutzer Identifikation Nachdem Git installiert ist, sollte Namen und E-Mail Adresse konfiguriert werden.

git config --global user.name 'Vorname Nachname'
git config --global user.email '[email protected]'

Jeder Commit wird unveränderbar mit diese beiden Information versehen.

Wen Git Privat und Geschäftlich benutzt wird kann es hilfreichsein eine fehlermeldung zu erzeugen wenn bei einem Commit keine Benutzer für das Repositorie gesetz wurde.

git config --global user.name $(perl -e 'print "x"x968;') 
git config --global user.email 'ILLEGAL_VALUE' 

Aliase

Es gibt einige nützliche Aliase welche definiert werden können.

git config --global alias.st 'status'
git config --global alias.ci 'commit'
git config --global alias.br 'branch'
git config --global alias.co 'checkout'
git config --global alias.df 'diff'
git config --global alias.dc 'diff --cached'
git config --global --add alias.root '!pwd'
git config --global alias.lg 'log -p'
git config --global alias.lol 'log --graph --decorate --pretty=oneline --abbrev-commit'
git config --global alias.lola 'log --graph --decorate --pretty=oneline --abbrev-commit --all'
git config --global alias.lold "log --graph --decorate --pretty=format:'%Cgreen%h%Creset%Cblue%d%Creset was %an, %Cred%ar%Creset %s' --abbrev-commit"
git config --global alias.lolda "log --graph --decorate --pretty=format:'%Cgreen%h%Creset%Cblue%d%Creset was %an, %Cred%ar%Creset %s' --abbrev-commit --all"
git config --global alias.ls 'ls-files'
git config --global alias.pup '!f() { cd . && git submodule foreach git fetch origin --tags && git submodule update --init --recursive && git submodule status; }; f'

Bei diesen Aliasen muss noch Username und E-Mail angepasst werden. (Geschäftlich / Private)

git config --global alias.business-repo '!f() { cd . && git config --local user.name "Vorname Nachname" && git config --local user.email "[email protected]"; }; f'
git config --global alias.private-repo '!f() { cd . && git config --local user.name "Vorname Nachname" && git config --local user.email "[email protected]"; }; f'

Hilfreiche Farben

Um das ganze Farbiger zu haben kann folgendes definieren werden.

git config --global color.ui 'auto'
git config --global color.branch.current 'yellow reverse'
git config --global color.branch.local 'yellow'
git config --global color.branch.remote 'green'
git config --global color.diff.meta 'yellow bold'
git config --global color.diff.frag 'magenta bold'
git config --global color.diff.old 'red bold'
git config --global color.diff.new 'green bold'
git config --global color.status.added 'yellow'
git config --global color.status.changed 'green'
git config --global color.status.untracked 'cyan'
git config --global color.ui 'true'
git config --global color.diff.whitespace 'red reverse'
git config --global core.whitespace 'fix,-indent-with-non-tab,trailing-space,cr-at-eol'
git config --global core.quotepath 'false'

Grafisch Darstellung von Differenzen

Es eignet sich die Unterschiede zweier Versionen eines Files Grafisch darzustellen.

git config --global merge.tool opendiff
git config --global diff.external '~/bin/opendiff-git.sh'

Benutzer bin ordnet erstellen

mkdir ~/bin
chflags hidden ~/bin

Shell Script erstellen

vi ~/bin/opendiff-git.sh

Shell Script

#!/bin/sh 
/usr/bin/opendiff "$2" "$5" -merge "$1"

Script ausführbar machen.

chmod +x ~/bin/opendiff-git.sh

Default Editor

Sublime Text 2 als Default Editor

git config --global core.editor "subl -n -w"
@jboehler
Copy link
Author

Setup p4merge as a visual diff tool

https://gist.github.com/tony4d/3454372

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment