From c191f90c7766ee6d5f24e90b552a6d446f0d02e4 Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Tue, 6 Apr 2021 11:11:08 +0300 Subject: [PATCH] Add discard snippets --- snippets/discard-uncommitted.md | 17 +++++++++++++++++ snippets/discard-untracked.md | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 snippets/discard-uncommitted.md create mode 100644 snippets/discard-untracked.md diff --git a/snippets/discard-uncommitted.md b/snippets/discard-uncommitted.md new file mode 100644 index 000000000..1a231c5b3 --- /dev/null +++ b/snippets/discard-uncommitted.md @@ -0,0 +1,17 @@ +--- +title: Discard uncommitted changes +tags: branch,intermediate +--- + +Discards all uncommitted changes to the current branch. + +- Use `git reset --hard HEAD` to reset the local directory to match the latest commit and discard all unstaged changes. + +```sh +git reset --hard HEAD +``` + +```sh +git reset --hard HEAD +# Discards all unstaged changes +``` diff --git a/snippets/discard-untracked.md b/snippets/discard-untracked.md new file mode 100644 index 000000000..b8d6d406e --- /dev/null +++ b/snippets/discard-untracked.md @@ -0,0 +1,17 @@ +--- +title: Discard untracked changes +tags: branch,intermediate +--- + +Discards all untracked changes to the current branch. + +- Use `git clean -f -d` to discard all untracked changes to the current branch. + +```sh +git clean -f -d +``` + +```sh +git clean -f -d +# Discards all untracked changes +```