Add undo snippets
This commit is contained in:
17
snippets/undo-commit.md
Normal file
17
snippets/undo-commit.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Undo a commit
|
||||
tags: commit,branch,intermediate
|
||||
---
|
||||
|
||||
Undoes a specified commit without rewriting history.
|
||||
|
||||
- Use `git revert <commit>` to revert the specified `<commit>`, creating a new commit with the inverse of the commit's changes.
|
||||
|
||||
```sh
|
||||
git revert <commit>
|
||||
```
|
||||
|
||||
```sh
|
||||
git revert 3050fc0d3
|
||||
# Reverts the commit `3050fc0d3`
|
||||
```
|
||||
17
snippets/undo-last-commit.md
Normal file
17
snippets/undo-last-commit.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Undo the last commit
|
||||
tags: commit,branch,intermediate
|
||||
---
|
||||
|
||||
Undoes the last commit without rewriting history.
|
||||
|
||||
- Use `git revert HEAD` to revert the last commit, creating a new commit with the inverse of the commit's changes.
|
||||
|
||||
```sh
|
||||
git revert HEAD
|
||||
```
|
||||
|
||||
```sh
|
||||
git revert HEAD
|
||||
# Reverts the last commit
|
||||
```
|
||||
Reference in New Issue
Block a user