0 votes
1 view
in Devops and Agile by (19.5k points)
edited by

I have a project in which I ran git init. After several commits, I did git status which told me everything was up to date and there were no local changes.

Then I made several consecutive changes and realized I wanted to throw everything away and get back to my original state. Will this command do it for me?

git reset --hard HEAD

1 Answer

0 votes
by (33.8k points)

To revert changes done to your working directory

git checkout .

To revert changes made to the index

git reset --hard

Warning: This will reset all unpushed commits to master.

To revert a change that you have committed 

git revert <commit 1> <commit 2>

To remove untracked files 

git clean -f

To remove untracked directories 

git clean -fd

...