Deleting files

To remove a file from git, simply delete it.

Mistakenly deleted a file?

If you removed a file, FooBar.java, but then thought better of it before committing, do what's below. Nota bene: you can add multiple filenames to each of these git reset -- or git checkout -- commands to save time.

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged ..." to unstage)
	deleted:    project/src/main/java/com/windofkeltia/FooBar.java

$ git reset -- project/src/main/java/com/windofkeltia/FooBar.java
Unstaged changes after reset:
D	project/src/main/java/com/windofkeltia/FooBar.java
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm ..." to update what will be committed)
  (use "git restore ..." to discard changes in working directory)
	deleted:    project/src/main/java/com/windofkeltia/FooBar.java

$ git checkout -- project/src/main/java/com/windofkeltia/FooBar.java
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged ..." to unstage)