Git, Aliases, Submodules and Symfony
Datum: 19.12.2010 11:42:19Some time ago i stumpled over Joel Perras (@jperras) blogentry Making Git Behave on twitter, covering the .gitconfig file and that was when I first found out about gits aliases and thanks to Joel I started to fill my gitconfig with more and more of them, speeding up my work with git und my working-environment for my mostly symfony based stuff.
For symfony-projects I am using a lot of submodules in git for symfony itself, all self written plugins, many third-party plugins [sfImageTransformExtraPlugin, sfLessPhpPlugin, ... ] and since some of the commands are long and I have to type them often, when working on the plugins I created my own set of aliases for optimizing my workflow with symfony, git and submodules. For different calls to git submodule foreach, like pulling/pushing all submodules, opening git gui for all submodules which have changes in them and more.
[alias]
# Sources:
# - Joel Perras ( @jperras http://nerderati.com/2010/07/making-git-behave/ )
# - http://www.commandlinefu.com/commands/view/4519/list-all-authors-of-a-particular-git-project
# - http://www.jukie.net/bart/blog/pimping-out-git-log
# - http://stackoverflow.com/questions/466764/show-ignored-files-in-git
# - https://git.wiki.kernel.org/index.php/Aliases
# [s = status] short status
s = "status -s"
# [b = branch]
b = "branch -a"
# [g = gui]
g = "!git gui &"
# [q = qgit]
q = "!qgit &"
# [m = meld] Opens meld the diff-viewer with current directory
m = "!meld . &"
# unadd - removes files/directories from staging
unadd = rm -r --cached
# gitk
k = !gitk --all --select-commit=HEAD &
# launches diffuse diff viewer showing modified files
diffuse = !diffuse --modified
# [l = log] short one line logs with ref-names
l = log --oneline --decorate=short
# [l = log] short one line logs with ref-names, date and author - nice colored
l2 = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --date=relative
# [gl = graph log]
gl = log --oneline --decorate --stat --graph
# [r = remote] listing remotes with urls
r = remote -v
# [dfb = diff before pull]
dfb = diff ORIG_HEAD HEAD
# [sf = submodule foreach] shortcut when running something on all submodules - eg. git sf "git s"
sf = submodule foreach
# [c = count] number of commits in current branch
c = "!git log --oneline | wc -l "
# cc clean and compress the repository [be carefull, can use a lot of RAM and take long on big repositories]
cc = "!du -hs .git; git gc --aggressive; du -hs .git;"
# [co = checkout]
co = checkout
# shows ignored directories
ignored = "!git ls-files --others -i --exclude-standard --directory"
# [ci = commit]
ci = commit
# [aa = add all] Adds all files
aa = add .
# [rs = reset hard] Resets modified files to state of last commit
rh = reset --hard
# [h = hash] hash of HEAD
h = rev-list --max-count=1 HEAD
# [shc = submodule hash] Shows current sha1s of all submodules and number of commits
shc = "!git sf 'git h; git c'"
# [llm = last log message] Shows the last git logentry (hash, author, date commitmessage)
llm = log -1
# [lcm = last log messages submodules] Last log message of all submodules
llms = !git sf "git llm;"
# [siu = submodule init update] Runs submodule-initialisation and update after a fresh checkout RECURSIVE!
siu = "!git submodule init; git submodule update; git submodule foreach \"git siu\""
# Pushs all submodules to origin master
pushsub = submodule foreach "git push origin master"
# Pull submodules from origin master
pullsub = submodule foreach "git pull origin master"
# [icg = if changed gui] Opens git gui if there are changes in the repository
icg = "!REPOCHANGED=`git s`; REPOCHANGED=${#REPOCHANGED}; if [ $REPOCHANGED != 0 ]; then git gui & fi;"
# Open git guis for all submodules which have changes
subgui = "submodule foreach git icg"
# [ul = user list] show users which have commits in current branch
ul = "!git log --format='%aN' | sort -u"
# [uccl = user commit count list ;)] show users which have commits in current branch, including number of commits, sorted (most commits last)
uccl = "!git log --format='%aN <%aE>' | awk '{arr[$0]++} END{for (i in arr){print arr[i], i;}}' | sort -n"
# [ahg = archive head gzip] creates a tar.gz archive named after the last commits hash from HEAD! in the directory above the repository
ahg = "!git archive HEAD --format=tar | gzip > ../`git h`.tar.gz"
The comments should explain the aliases, if not, just ask.
Another resource for some aliases is the git wiki on kernel.org: Git Aliases.
Trackbacks (0)
Trackbackurl: http://www.robo47.net/trackback/blogentry/208Es sind keine Trackbacks vorhanden.
You liked it ? Link it on your homepage or blog:



Benjamin Steininger ist Webentwickler auf der Suche nach einem neuen Job und
photographiert sehr gerne. Er beschäftigt sich viel mit dem Internet, PHP, Symfony, Testing und hat einen
Kommentare (0)
Es sind noch keine Kommentare vorhanden.
Die Kommentare zu diesem Beitrag sind gesperrt.