From 9f1fbc5861859061987b76264888a528e4ad3217 Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Mon, 11 May 2015 14:00:10 +0700 Subject: [PATCH] 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. --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 2cff35a..171f15a 100644 --- a/README.md +++ b/README.md @@ -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 ``` + +## I want to move my unstaged edits to a new branch + +```sh +$ git checkout -b new-branch +``` + + +## I want to move my unstaged edits to a different, existing branch + +```sh +$ git stash +$ git checkout branch2 +$ git stash pop +``` + ## What did I just do?