Here is a reference list of some useful GIT commands which I use including GIT Aliases commands. If you know of or use any which are not here please post a comment so I can add them to help others! :)

GIT Bash

GIT Bash for Windows (formerly known as GitWin) is shell command line tool for Windows users. It is essentially a Windows port of GNU bash “Minimalist GNU for Windows” (see msysgit projects website for more details).
Download GIT Bash

Useful GIT Commands

Show all branches.

$ git branch --all

git-branch-all

Load GITK (Generalized Interface Toolkit) Good for seeing what changes have been made and who by in a nice interface.

$ gitk

gitk

Add (if applicable) and commit changes with a message.

git commit -a -m "msg"

Search the tree contents for specific phrase and filetype. ie find the word “CSS” in all .js files.

git grep "css" -- *.js

Create a zipped backup of the current branch.

$ git archive --format=zip master^>backup-10-04-2013.zip

View local GIT config.

$ cat .git/config

Useful GIT Alias Commands

GIT Alias Commands can save you heaps of time typing in long-winded commands into your GIT CMD. They basically map a long command into whatever shorthand version you wish. They also can be configured to prettify/colorify your results. Official post on git alias commands. Also see: Must Have Git Aliases: Advanced Examples.

Show a pretty git log history.

$ git config --global alias.history "log --abbrev-commit --pretty=oneline --graph --decorate"
usage: $ git history

git-history

Show the last commit.

$ git config --global alias.last 'log -1 HEAD'usage: $ git last
usage: $ git last

Reset to state of your last commit.

$ git config --global alias.resetlast 'reset --hard HEAD'
usage: git resetlast
Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. Sam is driven and passionate about sharing his knowledge to educate others.

Free Guide:

How to Choose the Right Charting Library for Your Application

How do you make sure that the charting library you choose has everything you need? Sign up to receive this detailed guide from FusionCharts, which explores all the factors you need to consider before making the decision.


No Reader comments

Learn JavaScript for free!
Free course: Introduction to JavaScript

Yours when you take up a free 14-day SitePoint Premium trial.