Re: [PATCH] add commit --interactive
- From
David Kågedal <davidk@lysator.liu.se>
- Date
- Mar 2, 2007, 12:47 UTC
- Message-ID
- <87hct3zuay.fsf@morpheus.local>
- In-Reply-To
- <7v649ki3h1.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 5 quoted lines
> Probably the operation would go like this. I'll describe them > in terms of lower level operations, and leave the scripting to > others. > > * Stashing the current state
[...]
> * Switch to the commit you want to apply part of what was
[...]
> * Trickle some of the stashed changes in, perhaps interactively:
[...]
> * Review and test the change in the working tree. This does not
[...]
> * Then this is the tricky and interesting part. We need to > subtract the change we already used to advance HEAD from > "stashed changes". I do not think we currently have a single > command to do this step, but it would probably go like this.
What I would want to do here is to simply restore the original "stash" tree, so something like "git checkout stash -- ." would probably work.
The reason is that what I would consider a common scenario is that I realize that some of the changes I made should be commited first, and I extract them the way you describe, and maybe update them to erase traces of things I don't want to commit, perhaps on the same source lines.
But then I want to continue where I was, and reintroduce the things I cleaned away in the previous step.
This is also much simpler to do. So let's make two scripts "git-stash" and "git-unstash"
# git-stash:
git-commit -m "temporary stash"
git-tag stash
git-reset --hard HEAD^ # git-unstash:
git-checkout stash -- .
# or possibly:
#current=$(git-rev-parse HEAD)
#git-checkout stash
#git-reset --mixed $current
git-tag -d stashThen I would do this:
[ ... hack hack ... ] $ git stash $ git pick stash [ ... cleanup ... ] $ git commit -a -m "first change" $ git unstash
-- David Kågedal