From d35c63e0f1546e421c5d61694ab84b48f5a25de7 Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Tue, 6 Apr 2021 16:54:22 +0300 Subject: [PATCH] Add undo snippets --- snippets/undo-commit.md | 17 +++++++++++++++++ snippets/undo-last-commit.md | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 snippets/undo-commit.md create mode 100644 snippets/undo-last-commit.md diff --git a/snippets/undo-commit.md b/snippets/undo-commit.md new file mode 100644 index 000000000..ba33c4259 --- /dev/null +++ b/snippets/undo-commit.md @@ -0,0 +1,17 @@ +--- +title: Undo a commit +tags: commit,branch,intermediate +--- + +Undoes a specified commit without rewriting history. + +- Use `git revert ` to revert the specified ``, creating a new commit with the inverse of the commit's changes. + +```sh +git revert +``` + +```sh +git revert 3050fc0d3 +# Reverts the commit `3050fc0d3` +``` diff --git a/snippets/undo-last-commit.md b/snippets/undo-last-commit.md new file mode 100644 index 000000000..1a3fd8676 --- /dev/null +++ b/snippets/undo-last-commit.md @@ -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 +```