I frequently need to do this when setting up or syncing my various machines, and I seem to forget the command all the time. So let's say you've got more than one branch on your remote, and you want to bring it down into your local repository as well:

Stashing is a great way to pause what you're currently working on and come back to it later. For example, if you working on that awesome, brand new feature but someone just found a bug that you need to fix. Add your changes to the index using

@git add .@

@@ -24,3 +22,7 @@ You can also do multiple layers of stashes, so make sure to use

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:

<code>git stash apply stash@{1}</code>

+

+You can also easily apply the top stash on the stack by using ("Thanks jamesgolick!":http://jamesgolick.com/):

+This is a topic that is a constant source of confusion for many git users, basically because there's more than one way to skin the proverbial cat. Let's go over some of the basic commands that you'll need to undo your work.

+

+So, you just want to revert one file back to its original state:

+

+@git checkout <file>@

+

+One problem with this is that you may have is that a file and branch named the same. Since the checkout command is used for both reverting files and swapping out to a different branch, you'll need to use this syntax (thanks, "Norbauer":http://norbauer.com/notebooks/code/notes/git-revert-reset-a-single-file)

+

+@git checkout -- <file>@

+

+If you want to throw out all of the changes you've been working on, there's two ways to do that.

+

+@git checkout -f@ or @git reset --HARD@

+

+Once these commands are run you'll lose all of the work that isn't committed in your directory, so make sure to take caution when using them.

+

+Also, be aware that "'git revert' is not equivalent to 'svn revert'!":http://bryan-murdock.blogspot.com/2007/07/git-revert-is-not-equivalent-to-svn.html @git-revert@ is used to reverse commits, something another tip will cover in the future.