From: Duy Nguyen Date: Sat, 23 Mar 2013 09:59:49 GMT Subject: Re: Hard reset of a subdirectory in a sparse checkout setting Message-ID: In-Reply-To: <514C3249.7000100@ivt.baug.ethz.ch> On Fri, Mar 22, 2013 at 5:28 PM, Kirill Müller wrote: > 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