Skip to content

Instantly share code, notes, and snippets.

@MorbosVermin
Last active August 29, 2015 14:05
Show Gist options
  • Save MorbosVermin/d3d04150511db73c166a to your computer and use it in GitHub Desktop.
Save MorbosVermin/d3d04150511db73c166a to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Provides useful information for a GIT repo. Place somewhere in your PATH
# and you should be able to simply execute 'git info' or 'git-info' to
# execute.
#
# Check for git binary.
git=`which git`
[ -z "${git}" ] && echo "Error: git is required to be installed." && exit 1;
# Configures colors for terminal. Not required.
. $HOME/.bash_colors
# Only run if .git directory exists.
if [ -d .git ]; then
tag=`git describe`
url=`cat .git/config | grep url | awk '{print $3}'`
echo -e "${boldwhite}GIT repo:${clear} ${boldblue}${url}${clear} (${boldblue}${tag}${clear})"
#echo -e "${boldwhite}Remote Repos:${clear}"
#git remote -v
#echo
echo -e "${boldwhite}Latest Log Entry:${clear}"
git log --max-count=1
echo
echo "* GIT Help..."
echo -e " $ ${green}git log${clear} #for more logs or 'git show' for full commit details."
echo -e " $ ${green}git fetch -t${clear} #to retrieve an updated list of remote branches/versions/tags available."
echo -e " $ ${green}git checkout <tag>${clear} #to checkout the branch/version/tag."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment