Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

You have a lot of files to be indexed/staged with git add and then committed afterwards however, you want to avoid all the files by also reverting the changes to them. To do that git checkout -- . is used. For more information, click git checkout link.


Check the current status


inanzzz@inanzzz:~/project$ git status
On branch my-feature-branch
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: file_two.txt

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: file_one.txt
modified: file_two.txt

Untracked files:
(use "git add <file>..." to include in what will be committed)

file_seven.txt
file_six.txt

Remove all tracked files


As we can see "file_one.txt" and "file_two.txt" have been removed.


inanzzz@inanzzz:~/project$ git checkout -- .
inanzzz@inanzzz:~/project$ git status
On branch my-feature-branch
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: file_two.txt

Untracked files:
(use "git add <file>..." to include in what will be committed)

file_seven.txt
file_six.txt