Comment on How do I remove a file from a git commit?

VibeSurgeon@piefed.social ⁨6⁩ ⁨days⁩ ago

If it’s the last commit, you can undo the commit, and re-make it as you please by using git reset HEAD~1. You can then stage the files you actually want in the commit.

Another option is to amend the commit to not include that file, by doing git rm --cached <filename> followed by git commit --amend.

The reason you can’t do the prior in a separate follow-up commit is that the file would still be in the git history, and hence it must be pushed to GitHub along with the rest of the repo files.

If the problem is not on the latest commit, you can do an interactive rebase, and re-do the commit that way.

source
Sort:hotnewtop