Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k 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 (50.2k 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

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...