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