

To install newer versions of Git, you can check this tutorial. Note : Git 2.23 was released in August 2019 and you may not have this version already available on your computer. Since Git 2.23, there is a new way to remove files from commit, but you will have to make sure that you are using a Git version greater or equal than 2.23. Remove File From Commit using Git Restore To verify that the files were correctly removed from the repository, you can run the “ git ls-files” command and check that the file does not appear in the file (if it was a new one of course) $ git ls-files

When you are done with the modifications, you can simply commit your changes again with the “–amend” option. If you are simply not interested in this file anymore, you can use the “ git rm” command in order to delete the file from the index (also called the staging area). Note : this time, you are resetting from HEAD as you simply want to exclude files from your staging area Now that your files are in the staging area, you can remove them (or unstage them ) using the “git reset” command again. When running this command, you will be presented with the files from the most recent commit (HEAD) and you will be able to commit them. In order to remove some files from a Git commit, use the “git reset” command with the “–soft” option and specify the commit before HEAD. Remove File From Commit using Git Restore.
