Git Info — Almost Like “svn info” Monday, February 9th, 2009 · 18 Comments I have been trying to find something like svn info but for Git. Luckily, I stumbled upon Duane Johnson’s script. Here’s git-info.sh: #!/bin/bash # author: Duane Johnson # email: firstname.lastname@example.org # date: 2008 Jun 12 # license: MIT # # Based on discussion at http://kerneltrap.org/mailarchive/git/2007/11/12/406496 pushd . >/dev/null # Find base of git directory while [ ! -d .git ] && [ ! `pwd` = "/" ]; do cd ..; done # Show various information about this git directory if [ -d .git ]; then echo "== Remote URL: `git remote -v`" echo "== Remote Branches: " git branch -r echo echo "== Local Branches:" git branch echo echo "== Configuration (.git/config)" cat .git/config echo echo "== Most Recent Commit" git —no-pager log —max-count=1 echo echo "Type 'git log' for more commits, or 'git show' for full commit details." else echo "Not a git repository." fi popd >/dev/null I made an alias in my .profile to make it a bit more accessible: alias gi='. /Users/$USER/git-info.sh' 18 Comments Comments Feed LeoB August 24, 2010 at 12:34 PM Thanks for that. ‘was hoping git would have something better than “cat .git/config” but no 😀 Nice little script anyway sherwin September 4, 2011 at 12:27 AM No problem ^^ Fabrizio March 1, 2011 at 6:49 AM Cool, I like this 🙂 sherwin September 4, 2011 at 12:27 AM Nice to know =) bread May 2, 2011 at 11:05 AM Thank you! Daniel sherwin September 4, 2011 at 12:27 AM You’re welcome Daniel. Nice avatar haha Iman Samizadeh September 1, 2011 at 5:46 AM Thanks dude. sherwin September 4, 2011 at 12:27 AM You are welcome. Hope it was helpful. Michael Fairchild April 15, 2012 at 9:09 AM the git log line did not work with my version, 126.96.36.199. I replaced it with git –no-pager log –pretty=format:’%h was %an, %ar: %s’ –graph ‑n 10 which now gives nice compact output of the last 10 commits, such as * 0f4acd3 was Michael, 2 months ago: Merge branch ‘master’ of http://github.com/mxcl/homebrew |\ | * b769471 was Adam Vandenberg, 2 months ago: uwsgi: remove verbose warning | * 0228551 was Peter Hollows, 4 months ago: polipo: launchd plist | * 6d32041 was Jonas Bengtsson, 4 months ago: elinks: enable 256 colors Sherwin April 15, 2012 at 9:11 AM Thanks Michael. Evandro May 14, 2013 at 3:07 AM that’s because — (two dashes) get replaced by a – (long dash) qa May 30, 2012 at 8:37 PM Hi what if i want all these in my application..i want to display the same[git last commit,git url etc] in my “About my project page” which i have done in rails Mark July 17, 2012 at 11:08 AM You don’t like cat .git/config ?? Try this: $ git-config -l ; # aka git-config --list Marcello De Sales August 13, 2012 at 4:05 PM Awesome… I have used the patch from Michael… thanks! Sherwin October 23, 2012 at 3:07 AM I’ve done something similar but edited my .gitconfig directly w/ suggestions here: http://j.mp/OYAoQB (Stackoverflow post) Michael September 21, 2012 at 4:21 AM cool script. this command is a bit bogus: git —no-pager log —max-count=1 it should be git log –max-count=1 Antonio Hdez. Blas December 3, 2013 at 10:54 PM Hi, you can drop git-info (as executable) at your ‘git-core’ directory and then you can just execute ‘git info’ inside your repository, no need for the alias in your shell. This also means that ‘git info’ would be available for all the users in your system. In Slackware ‘git-core’ directory is /usr/libexec/git-core/. - Cheers Sherwin December 5, 2013 at 12:12 AM Thanks for that tip Antonio.