I know how to revert to previous commit. But now I did a lot of work since I committed and I want to restart and start from scratch straight from my current commit.
How do I do that?
I know how to revert to previous commit. But now I did a lot of work since I committed and I want to restart and start from scratch straight from my current commit.
How do I do that?
git reset --hard
is the easiest one... but it does get rid of everything that's hanging around. You might also consider just saving it in the stash and dump it later on when you are sure you won't need it anymore.
git stash push -m "Saving this in case I want to use it later on"
That will clean up the working tree.
The latest commit in the current branch is referenced by HEAD
, you could just git reset
to it:
$ git reset HEAD --hard
If you have created new files or directories that you need to get rid of, you can also use git clean -fd
to remove those.
To revert changes in tracked files you can do git reset --hard
which will remove all new code since your last commit.