How do I return my working directory to the state it would be in if I made a new clone and checked out the current version?
For subversion I'd do:
$ svn status --no-ignore | awk '$1 == "?" { print $2 }' | xargs rm -r
and for mercurial:
$ hg status --ignored --unknown | awk ' ( $1 == "?" ) || ( $1 == "I") { print $2 }' | xargs rm -r
So answers in the same line are fine. But something like git checkout --clean -r b4a23
would be better.
(prepare to loose all local, uncommited changes:)
git reset --hard
git clean -dfx .
As mentioned, you can use git stash
to temporarily save a reference to your local pending changes on a 'pseudo branch' (i.e. a stash).
In addition to @sehe's answer, you may want to create an alias to make it easier.
git config --global alias.pristine '!git reset --hard && git clean -dffx'
Then you may just call git pristine
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With