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