1
0
mirror of https://github.com/k88hudson/git-flight-rules.git synced 2025-03-10 12:48:43 -03:00

Show how a newly added file can be removed (#164)

This shows how the user can remove a newly added file from the
previous commit.
This commit is contained in:
Kaartic Sivaraam 2017-12-05 02:27:20 +05:30 committed by Richard Littauer
parent 231b474600
commit 0e478ad4cc

View File

@ -153,6 +153,13 @@ $ git add myfile
$ git commit --amend --no-edit $ git commit --amend --no-edit
``` ```
In case the file was newly added to the commit and you want to remove it (from Git alone), do:
```sh
$ git rm --cached myfile
$ git commit --amend --no-edit
```
This is particularly useful when you have an open patch and you have committed an unnecessary file, and need to force push to update the patch on a remote. The `--no-edit` option is used to keep the existing commit message. This is particularly useful when you have an open patch and you have committed an unnecessary file, and need to force push to update the patch on a remote. The `--no-edit` option is used to keep the existing commit message.
<a name="delete-pushed-commit"></a> <a name="delete-pushed-commit"></a>