Files
30-seconds-of-code/git/s/remove-file-from-commit.md
Angelos Chalaris 5c913d20bd Reorganize snippets
2023-05-03 21:19:02 +03:00

589 B

title, type, language, tags, cover, dateModified
title type language tags cover dateModified
Remove a file from the last commit snippet git
commit
cancel-typographer 2021-04-13T21:10:59+03:00

Removes a file from the last commit without changing its message.

  • Use git rm —-cached <file> to remove the specified <file> from the index.
  • Use git commit —-amend to update the contents of the last commit, without changing its message.
git rm —-cached <file>
git commit —-amend
git rm —-cached "30-seconds.txt"
git commit —-amend
# Removes `30-seconds.txt` from the last commit