Skip to content

Commit

Permalink
Merge pull request k88hudson#103 from codeofcarson/master
Browse files Browse the repository at this point in the history
Add a new rule, how to discard specific unstaged changes
  • Loading branch information
RichardLitt authored Dec 29, 2016
2 parents 25bb25a + eb48bfc commit bad1b36
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ For clarity's sake all examples in this document use a customized bash prompt in
- [I want to move my unstaged edits to a new branch](#i-want-to-move-my-unstaged-edits-to-a-new-branch)
- [I want to move my unstaged edits to a different, existing branch](#i-want-to-move-my-unstaged-edits-to-a-different-existing-branch)
- [I want to discard my local, uncommitted changes](#i-want-to-discard-my-local-uncommitted-changes)
- [I want to discard specific unstaged changes](#i-want-to-discard-specific-unstaged-changes)
- [Branches](#branches)
- [I pulled from/into the wrong branch](#i-pulled-frominto-the-wrong-branch)
- [I want to discard local commits so my branch is the same as one on the server](#i-want-to-discard-local-commits-so-my-branch-is-the-same-as-one-on-the-server)
Expand Down Expand Up @@ -279,6 +280,28 @@ To reset only a specific file, you can use that the filename as the argument:
$ git reset filename
```

<a href="i-want-to-discard-specific-unstaged-changes"></a>
### I want to discard specific unstaged changes

When you want to get rid of some, but not all changes in your working copy.

First strategy, stash all good changes, reset working copy, reapply good changes.

```sh
$ git stash -p
# Select all of the snippets you want to save
$ git reset --hard
$ git stash pop
```

Alternate strategy, stash undesired changes, drop stash.

```sh
$ git stash -p
# Select all of the snippets you don't want to save
git stash drop
```

## Branches

<a name="pull-wrong-branch"></a>
Expand Down

0 comments on commit bad1b36

Please sign in to comment.