Add undo snippets

This commit is contained in:
Isabelle Viktoria Maciohsek
2021-04-06 16:54:22 +03:00
parent 81b0c17a6a
commit d35c63e0f1
2 changed files with 34 additions and 0 deletions

17
snippets/undo-commit.md Normal file
View 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`
```

View 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
```