Re: Hard reset of a subdirectory in a sparse checkout setting
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 23, 2013, 09:59 UTC
- Message-ID
- <CACsJy8DmkMWOx-u2=trz+GTtwpbksTbCvUU+AOQYo5SrNtM2Gw@mail.gmail.com>
- In-Reply-To
- <514C3249.7000100@ivt.baug.ethz.ch>
On Fri, Mar 22, 2013 at 5:28 PM, Kirill Müller <kirill.mueller@ivt.baug.ethz.ch> wrote:
Show 12 quoted lines
> I can't find a neat way to "git reset --hard" a subdirectory of a checkout > without reading in directories or files which are excluded by a sparse > checkout. This has been asked on StackOverflow in greater detail, but the > "right" answer is still missing: http://stackoverflow.com/q/15404535/946850 > > The options I see are: > > - git checkout . (will restore excluded directories) > > - git reset --hard (won't accept a path argument) > > - git diff | patch -R (awkward)
Another way is
git diff --name-only -z|xargs -0 git checkout
> What's the proper way to do this in Git?
I think adding --sparse to git checkout may be more user-friendly. And it looks like a simple change. I'll make a patch soon (I need some time to recall how sparse checkout interacts with git-checkout).
-- Duy