I'm using git for java projects and I did changes in many classes and I didn't do git add, git commit and push. And now I want to delete all my changes. How can I do that? Is there a git command because I don't want to delete all the code manually? Thank you!
Asked
Active
Viewed 2,057 times
1
-
1When you type `git status`, it will hint at using `git restore ... `. Would that solve your problem? – mnestorov Mar 02 '21 at 10:55
-
Try `git restore .` or `git reset --hard HEAD` – Prihex Mar 02 '21 at 12:17
-
Does this answer your question? [How do I discard unstaged changes in Git?](https://stackoverflow.com/questions/52704/how-do-i-discard-unstaged-changes-in-git) – Joe Mar 22 '21 at 10:21
3 Answers
2
You can try
git checkout .
or
git stash
git stash drop
or (assuming you're on branch master)
git reset --hard master

michid
- 10,536
- 3
- 32
- 59
-1
If you want to use git command, so look at this.
Another suggestion is you can use program that make you easy to use git, like GitHub Desktop, VSCODE version control. That tools have functions that you can make it easy to manage your git project.

Akrd Kmnc
- 92
- 7