Skip to content

Instantly share code, notes, and snippets.

@JeffreyWay
Created August 15, 2013 17:51
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save JeffreyWay/6242988 to your computer and use it in GitHub Desktop.
Save JeffreyWay/6242988 to your computer and use it in GitHub Desktop.
Ever want to undo everything that you've worked on since the last commit (including adding new files)? Here's a little alias to help with that.
alias gundo='git reset HEAD~ && git clean -df'
@zackkitzmiller
Copy link

I think this would be better in .gitconfig

[alias]
    undo = reset HEAD~ && clean -df

usage: $ git undo

@JeffreyWay
Copy link
Author

Yeah

@clarkeash
Copy link

Thats awesome, mainly because I had no idea you could add aliases in your .gitconfig, not a file I really touch. cheers @zackkitzmiller

@michaelryancaputo
Copy link

i'm getting a "unknown switch `d'"

@JeffreyWay
Copy link
Author

Hmm - are you using two dashes?

@michaelryancaputo
Copy link

Looks like i'm on version 1.7.12.4, that might be the issue. Copy/pasted directly form your gist.

@nicholasruunu
Copy link

This might be kind of relevant:

# Undo a `git push`
undopush = push -f origin HEAD^:master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment