1

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!

Prihex
  • 342
  • 2
  • 11
elvis
  • 956
  • 9
  • 33
  • 56
  • 1
    When 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 Answers3

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
0

After

git stash git stash drop

all files added to "staged"

Ramazan
  • 273
  • 3
  • 7
-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