Added two sections for moving unstaged edits

I often want to add commits to a new branch, and to an old branch that is empty, but I forget how. Here it is.
This commit is contained in:
Richard Littauer 2015-05-11 14:00:10 +07:00
parent 0f7027159a
commit 9f1fbc5861
1 changed files with 19 additions and 0 deletions

View File

@ -37,6 +37,9 @@ For clarity's sake all examples in this document use a customized bash prompt in
- [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)
- [I want to discard my local, uncommitted changes](#i-want-to-discard-my-local-uncommitted-changes)
- [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)
- [What did I just do?](#what-did-i-just-do)
- [I want to add changes in one file to two different commits](#i-want-to-add-changes-in-one-file-to-two-different-commits)
- [I want to remove a file from git but keep the file](#i-want-to-remove-a-file-from-git-but-keep-the-file)
- [Clone all submodules](#clone-all-submodules)
@ -444,6 +447,22 @@ If you want to only reset to some commit between origin and your local, you can
(master)$ git checkout -f
```
<a href="move-unstaged-edits-to-new-branch"></a>
## I want to move my unstaged edits to a new branch
```sh
$ git checkout -b new-branch
```
<a href="move-unstaged-edits-to-old-branch"></a>
## I want to move my unstaged edits to a different, existing branch
```sh
$ git stash
$ git checkout branch2
$ git stash pop
```
<a name="diff-last"></a>
## What did I just do?