Remove a file from the last Git commit
Have you ever made a commit only to realize that a file should not have been included? This is a common problem, yet it's fairly easy to fix. All you have to do is remove the file and then amend the last commit.
Simply, using git rm --cached <file>
removes the specified <file>
from the index, and git commit --amend
updates the contents of the last commit without changing its message.
# Syntax: # git rm --cached <file> # git commit --amend git rm --cached "30-seconds.txt" git commit --amend # Removes `30-seconds.txt` from the last commit