Merged two questions, as revert applies to both

This commit is contained in:
Richard Littauer 2015-08-18 15:57:09 -04:00
parent 4622e309f1
commit a9cb62514a
1 changed files with 2 additions and 7 deletions

View File

@ -50,8 +50,7 @@ For clarity's sake all examples in this document use a customized bash prompt in
- [Deleting Objects](#deleting-objects)
- [I want to delete local branches that were deleted upstream](#i-want-to-delete-local-branches-that-were-deleted-upstream)
- [I accidentally deleted my branch](#i-accidentally-deleted-my-branch)
- [Delete/remove last pushed commit](#deleteremove-last-pushed-commit)
- [Delete/remove last local commit](#deleteremove-last-local-commit)
- [I want to delete or remove my last commit](#i-want-to-delete-or-remove-my-last-commit)
- [Delete/remove arbitrary commit](#deleteremove-arbitrary-commit)
- [Delete tag](#delete-tag)
- [Deleted Patch](#deleted-patch)
@ -294,7 +293,6 @@ If you need to change all of history, see the man page for 'git filter-branch'
<a name="commit-wrong-branch"></a>
## I committed to master instead of a new branch
Create the new branch while remaining on master:
```
@ -646,7 +644,7 @@ README.md foo.txt
Voila! We got our removed file back. Git reflog is also useful when rebasing goes terribly wrong.
<a name="delete-pushed-commit"></a>
### Delete/remove last pushed commit
### I want to delete or remove my last commit
If you need to delete pushed commits, you can use the following. However, it will irreversabily change your history, and mess up the history of anyone else who had already pulled from the repository. In short, if you're not sure, you should never do this, ever.
@ -655,9 +653,6 @@ git reset HEAD^ --hard
git push -f [remote] [branch]
```
<a name="undo-commit"></a>
### Delete/remove last local commit
If you haven't pushed, to reset Git to the state it was in before you made your last commit (while keeping your staged changes):
```