From b3d4535e836bac020092bf21382d82d8d0bffb0a Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 22 May 2015 09:04:52 -0500 Subject: [PATCH] Add Stashing Only Unstaged Changes as a git til. --- README.md | 1 + git/stashing-only-unstaged-changes.md | 30 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 git/stashing-only-unstaged-changes.md diff --git a/README.md b/README.md index 691962c..712cad6 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Single Key Presses in Interactive Mode](git/single-key-presses-in-interactive-mode.md) - [Staging Changes Within Vim](git/staging-changes-within-vim.md) - [Staging Stashes Interactively](git/staging-stashes-interactively.md) +- [Stashing Only Unstaged Changes](git/stashing-only-unstaged-changes.md) - [Stashing Untracked Files](git/stashing-untracked-files.md) - [Verbose Commit Message](git/verbose-commit-message.md) diff --git a/git/stashing-only-unstaged-changes.md b/git/stashing-only-unstaged-changes.md new file mode 100644 index 0000000..7091cab --- /dev/null +++ b/git/stashing-only-unstaged-changes.md @@ -0,0 +1,30 @@ +# Stashing Only Unstaged Changes + +If you have both staged and unstaged changes in your project, you can +perform a stash on just the unstaged ones by using the `-k` flag. The +staged changes will be left intact ready for a commit. + +``` +$ git status +On branch master +... +Changes to be committed: + + modified: README.md + +Changes not staged for commit: + + modified: app/models/user.rb + +$ git stash -k +Saved working directory and index state ... + +$ git status +On branch master +... +Changes to be committed: + + modified: README.md +``` + +h/t [Chris Erin](https://twitter.com/MCNormalMode)