Git Info — Almost Like “svn info”

I have been try­ing to find some­thing like svn info but for Git. Luck­ily, I stum­bled upon Duane Johnson’s script. Here’s git-info.sh:

#!/bin/bash

# author: Duane Johnson
# email: duane.johnson@gmail.com
# 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 .pro­file to make it a bit more accessible:

alias gi='. /Users/$USER/git-info.sh'

8 Comments

Comments Feed · Trackback Address
  1. LeoB

    Thanks for that.

    was hop­ing git would have some­thing bet­ter than “cat .git/config” but no :D

    Nice lit­tle script anyway

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>