Skip to content

Commit

Permalink
Show how a newly added file can be removed (k88hudson#164)
Browse files Browse the repository at this point in the history
This shows how the user can remove a newly added file from the
previous commit.
  • Loading branch information
sivaraam authored and RichardLitt committed Dec 4, 2017
1 parent 231b474 commit 0e478ad
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ $ git add myfile
$ 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.

<a name="delete-pushed-commit"></a>
Expand Down

0 comments on commit 0e478ad

Please sign in to comment.