My git tips...
Ok, so a handy meme is loose: Handy Git tips. We even had a crazy anatidae requesting us to post this to the Git wiki whatever we send on this regard to our personal blogs.
Following Damog's post, I will also put my .bashrc snippet:
parse_git_branch() { branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` if [ ! -z "$branch" ] then if ! git status|grep 'nothing to commit .working directory clean' 2>&1 > /dev/null then branch="${branch}*" mod=`git ls-files -m --exclude-standard|wc -l` new=`git ls-files -o --exclude-standard|wc -l` del=`git ls-files -d --exclude-standard|wc -l` if [ $mod != 0 ]; then branch="${branch}${mod}M"; fi if [ $new != 0 ]; then branch="${branch}${new}N"; fi if [ $del != 0 ]; then branch="${branch}${del}D"; fi fi fi echo $branch }
This gives me the following information on my shell prompt:
- The git branch where we are standing
- If it has any uncommitted changes, a * is displayed next to it
- If there are changes not checked in to the index, M (modified), N (new) or D (deleted) is displayed, together with the number of files in said condition. i.e.,
Sometimes, entering a very large git tree takes a second or two... But once it has run once, it goes on quite smoothly.
Of course, I still have this also in .bashrc - but its funcionality pales in comparison:- get_svn_revision() {
- if [ -d .svn ]
- then
- svn info | grep ^Revision | cut -f 2 -d ' '
- fi
- }
I am sure it can be expanded, of course - but why? :)
- Bitácora de gwolf
- Log in or register to post comments