mirror of
https://github.com/k88hudson/git-flight-rules.git
synced 2025-03-10 12:48:43 -03:00
Iss-150: Fixed section about discarding local uncommitted changes (#160)
Iss-150: minor fix
This commit is contained in:
parent
5eaca03df3
commit
c128fff050
36
README.md
36
README.md
@ -295,25 +295,38 @@ $ git stash pop
|
||||
<a href="i-want-to-discard-my-local-uncommitted-changes"></a>
|
||||
### I want to discard my local, uncommitted changes
|
||||
|
||||
If you want to only reset to some commit between origin and your local, you can do this:
|
||||
This will unstage all files you might have staged with git add:
|
||||
|
||||
```sh
|
||||
# one commit
|
||||
(my-branch)$ git reset --hard HEAD^
|
||||
# two commits
|
||||
(my-branch)$ git reset --hard HEAD^^
|
||||
# four commits
|
||||
(my-branch)$ git reset --hard HEAD~4
|
||||
# or
|
||||
(master)$ git checkout -f
|
||||
$ git reset
|
||||
```
|
||||
|
||||
To reset only a specific file, you can use that filename as the argument:
|
||||
This will revert all local uncommitted changes (should be executed in repo root):
|
||||
|
||||
```sh
|
||||
$ git reset filename
|
||||
$ git checkout .
|
||||
```
|
||||
|
||||
You can also revert uncommitted changes to a particular file or directory:
|
||||
|
||||
```sh
|
||||
$ git checkout [some_dir|file.txt]
|
||||
```
|
||||
|
||||
Yet another way to revert all uncommitted changes (longer to type, but works from any subdirectory):
|
||||
|
||||
```sh
|
||||
$ git reset --hard HEAD
|
||||
```
|
||||
|
||||
This will remove all local untracked files, so only git tracked files remain:
|
||||
|
||||
```sh
|
||||
$ git clean -fdx
|
||||
```
|
||||
|
||||
WARNING: -x will also remove all ignored files!
|
||||
|
||||
<a href="i-want-to-discard-specific-unstaged-changes"></a>
|
||||
### I want to discard specific unstaged changes
|
||||
|
||||
@ -1257,4 +1270,3 @@ Using git reset it is then possible to change master back to the commit it was b
|
||||
* [Fork](https://git-fork.com/) - a fast and friendly git client for Mac (beta)
|
||||
* [gmaster](https://gmaster.io/) - a git client for Windows that has 3-way merge, analyze refactors, semantic diff and merge (beta)
|
||||
* [gitk](https://git-scm.com/docs/gitk) - a git client for linux to allow simple view of repo state.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user