git aliases: svn revert

People converting from svn to git often have a hard time finding an analogous process for their svn commands.

For something similar to svn revert, you need to do the following:

git clean -df
git checkout -- .

The first command will remove newly created files that have not yet been staged for commit. The second command reverts files that have been modified but not staged for commit.

You can make this a git alias by adding the following under the [alias] section of your .gitconfig file:

undo = !git clean -df && git checkout -- .

The above allows you to perform the commands by simply typing git undo You can choose any alias you want, though note that git revert is already a valid command.

If you have staged files and you want to remove them a swlel, you can add another alias (or amend the previous alias):

unstage = reset HEAD --

Hopefully this makes any svn folks more comfortable with their git transition.