[PATCH v4 0/5] Re: {checkout,reset,stash} --patch
- From
- Nicolas Sebrecht <nicolas.s.dev@gmx.fr>
- Date
- Aug 9, 2009, 21:28 UTC
- Message-ID
- <20090809212831.GA12932@vidovic>
- In-Reply-To
- <200908091844.43107.trast@student.ethz.ch>
The 09/08/09, Thomas Rast wrote:
Show 12 quoted lines
> Nicolas Sebrecht wrote: > > > > Also, I'd expect to have 'git reset --hard -p' discarding hunks from > > both the index and the WT (which is not possible for now unless I missed > > something). > > Well, the unfortunate overlap between 'git reset --hard' and 'git > checkout HEAD -- .' strikes again :-) > > Since you can't say 'git reset --hard -- file', you have to do 'git > checkout HEAD -- file' to achieve this effect. So this usage is > covered by 'git checkout -p HEAD'.
Not exactly:
Current branch: my_branch (clean) nicolas@vidovic git % echo 'hi' > file Current branch: my_branch (dirty: untracked:1) nicolas@vidovic git % git add file Current branch: my_branch (dirty: index) nicolas@vidovic git % git checkout -p No changes.
Same example with an already tracked file:
Current branch: my_branch (clean) nicolas@vidovic git % echo 'hi Thomas' >> Documentation/SubmittingPatches Current branch: my_branch (dirty: working_tree) nicolas@vidovic git % git add Documentation/SubmittingPatches Current branch: my_branch (dirty: index) nicolas@vidovic git % git checkout -p No changes.
So, we can discard a hunk from the index with 'git reset -p' without touching the WT. And we can discard a hunk from the WT with 'git checkout -p' without touching the index. But we can't discard a hunk from both the index and the WT.
IOW, we have (from the user POV):
.git --- (reset -p) ---> index
index --- (checkout -p) ---> WTWhat's missing:
.git ------------------ ( ??? ) --------------------> WT
-- Nicolas Sebrecht