How to do virgin check with git?

How to return my working directory to the state in which it would be if I made a new clone and check the current version?

For subversion, I would do:

$ svn status --no-ignore | awk '$1 == "?" { print $2 }' | xargs rm -r 

and for mercury:

 $ hg status --ignored --unknown | awk ' ( $1 == "?" ) || ( $1 == "I") { print $2 }' | xargs rm -r 

So the answers in one line are beautiful. But something like git checkout --clean -r b4a23 would be better.

+4
source share
3 answers

(prepare to release all local, unmanaged changes :)

 git reset --hard git clean -dfx . 

As already mentioned, you can use git stash to temporarily save a link to your local pending changes on a "pseudo-branch" (ie wallet).

+16
source

You can use git stash to save the current changes, then you can git stash apply to revert your changes.

0
source

Try git reset --hard <revision>

See this page for good examples for the reset command: http://linux.die.net/man/1/git-reset

0
source

Source: https://habr.com/ru/post/1395082/


All Articles