Add discard snippets
This commit is contained in:
17
snippets/discard-uncommitted.md
Normal file
17
snippets/discard-uncommitted.md
Normal file
@ -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
|
||||
```
|
||||
17
snippets/discard-untracked.md
Normal file
17
snippets/discard-untracked.md
Normal file
@ -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
|
||||
```
|
||||
Reference in New Issue
Block a user