Wie jeder Programmierer habe auch ich meine kleine Sammlung an Werkzeugen, die meine Arbeit schneller machen. Da man als Entwickler ab und zu auf einen neuen Rechner umzieht, lohnt es sich, diese Werkzeuge für sich selber zu dokumentieren, um sie auf dem nächsten Rechner wieder schnell aufsetzen zu können.

Ähnlich wie bei meinen Standard-Einstellungen in Sublime Text 3 habe ich für Git inzwischen jede Menge Einstellungen und Aliase erzeugt, die ich inzwischen auf jedem meiner Rechner im Einsatz habe.

Die Einstellungen werden einfach direkt von der Kommandozeile aus eingetragen, indem man die folgenden Zeilen ausführt:

#!/bin/bash
git config --global user.name "YOUR NAME"
git config --global user.email "YOURMAIL@example.com"
git config --global tag.sort version:refname
git config --global core.autocrlf false                 # https://stackoverflow.com/a/13154031/3232532
git config --system core.longpaths true                 # https://stackoverflow.com/a/22575737/3232532
git config --global alias.chmod 'update-index --add --chmod=+x' # FILE: Makes files executable in Git
git config --global alias.reset-unpushed 'reset HEAD~1' # Undo last commits which have not been pushed
git config --global alias.reset-pushed 'revert HEAD'    # Undo last commits which have been pushed
git config --global alias.reset-ultra '!f() { git reset --hard && git clean -f -d; }; f' # Undo everything before last commit
git config --global alias.tag-current 'describe --tags' # Shows current tag
git config --global alias.tag-sorted 'tag --sort=v:refname' # Show tags sorted
git config --global alias.remove-keep 'rm --cached -r'  # FILE: Remove from Git but keep locally
git config --global alias.acp '!f() { git add -A && git commit -m "$@" && git push; }; f' # Add, commit, push, https://stackoverflow.com/a/35049625/3232532
git config --global alias.delete-dangle '!f() { git fetch -p && for branch in `git branch -vv | grep ": gone]" | awk "{print $1}"`; do git branch -D $branch; done; }; f' # https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote
git config --global alias.graph 'log --oneline --graph' # Show commits as graph

# git show: Diff of latest commit
# git branch -r: Show all branches
# git merge --abort: Abort merge ;)

Gerade ein Git Alias spart mit der Zeit Unmengen an Nachschlage- und Denkarbeit, und dient nebenbei als gute Dokumentation für die Lösung komplexer Git-Probleme.


Andere Artikel zum Thema · · · ·

Zuletzt geändert am

fboës - Der Blog