From: Konstantin Khomoutov <kostix@bswap.ru>
To: Tim Chase <git@tim.thechases.com>
Cc: git@vger.kernel.org
Subject: Re: stashing only unstaged changes?
Date: Fri, 24 Jun 2022 12:55:58 +0300 [thread overview]
Message-ID: <20220624095558.hegsfj4e4nbqyooo@carbon> (raw)
In-Reply-To: <20220621142618.239b02cd@bigbox.attlocal.net>
On Tue, Jun 21, 2022 at 02:26:18PM -0500, Tim Chase wrote:
> I recently had composed a commit with some `git add -p` leaving some
> portions unstaged. I wanted to stash the unstaged changes to make
> sure that the staged code ran as expected, so I did a `git stash`
> only to find that it unstaged my staged changes and stashed
> *everything*.
I tend to rely on reflogs for this.
Basically, I roll like this:
1. Stage the necessary changes, commit.
2. Stage the remaining changes - what you've left unstaged in your case, -
commit.
3. Go to the commit I need to test; in this simple case that'd be
$ git checkout HEAD~
Then test the changes.
4. Go back to the previous state using the HEAD's reflog:
$ git checkout HEAD@{1}
If you now need to have the situation where the changes committed on step 2
are left only in the work tree, run
$ git reset HEAD~
so that you have the HEAD and the index reset to the commit recorded on step 1
with the changes from the commit 2 left in the work tree.
Having said that, I'd note that I tend to do work on the detached HEAD
but you could apply the same logic to working on a a branch.
next prev parent reply other threads:[~2022-06-24 9:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 19:26 stashing only unstaged changes? Tim Chase
2022-06-24 8:16 ` Reto
2022-06-24 20:53 ` Tim Chase
2022-06-24 9:55 ` Konstantin Khomoutov [this message]
2022-06-24 11:23 ` Erik Cervin Edin
2022-06-24 20:38 ` Tim Chase
2022-06-24 13:09 ` Ævar Arnfjörð Bjarmason
2022-06-24 13:49 ` Erik Cervin Edin
2022-06-24 15:32 ` Ævar Arnfjörð Bjarmason
2022-06-24 19:47 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220624095558.hegsfj4e4nbqyooo@carbon \
--to=kostix@bswap.ru \
--cc=git@tim.thechases.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).