Into the world of the command line – GIT BASHING

GIT Branching Example

GIT Branching Example

I’m fairly new to the world of GIT and Branching and so on. I started using GIT around January 2012 and to be honest I took me about 6 weeks just to get my head around it! Anyway, along that steep learning curve of GIT I came across a command called git stash. Not all GIT BASHER’s would agree but I actually really like this command.

Stashing is a really good way to pause what you’re currently working on and come back to it later. For example, if you working on a new feature to your web project but someone just found a error or bug that requires a hotfix. Just store your files until later.

What if you make changes in the wrong Branch (it happens!). This is another easy way to Stash your files modifications, checkout the correct Branch and restore your changes into the Branch.

Stash your changes away with:

git stash

And boom! You’re back to your original working state. Got that bug fixed? Bring your work back with:

git stash apply

You can also do multiple layers of stashes, so make sure to use

git stash list

To check out all of your current ones. If you need to apply a stash from deeper in the stack, that’s easy too. Here’s how to apply the second stash you’ve got:

git stash apply stash@{1}

You can also easily apply the top stash on the stack by using:

git stash pop

A note with this command, it deletes that stash for good, while apply does not. You can manually delete stashes with:

git stash drop

Or delete all of the stored stashes with:

git stash clear

The above I believe is pretty elementary, but I hope you find it useful all the same.  What commands do you find really handy or useful?  I would like to hear from you.


  1. One of the most commonly used commands is the ‘git log’ command. This command shows you the commit history of your project, so you can see what has happened up to this point. With no options, it will start from the last commit on the branch you’re currently on and show you all the commits that are ancestors of that in reverse chronological order.

  2. means “publish my master branch head as to-upstream branch at $URL”. See also git-push(1) .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.