How to remove a file from the index?
git rm --cached file_name
To remove a file from the index without deleting the actual file use git rm --cached file_name
.
git rm --cached image.png
rm 'image.png'
git status
On branch main
Changes to be committed:
(use "git restore --staged..." to unstage)
deleted: image.png
Untracked files:
(use "git add..." to include in what will be committed)
image.png
See git rm to learn more about it.