> From: Jacob Keller [mailto:jacob.keller@xxxxxxxxx] > Sent: Tuesday, September 12, 2017 7:39 PM > > On Tue, Sep 12, 2017 at 4:30 PM, Kevin Willford <kewillf@xxxxxxxxxxxxx> wrote: > > > > Sorry. It was not in the sparse-checkout file. > > $ git config core.sparsecheckout true > > $ echo /i > .git/info/sparse-checkout > > $ git checkout -f > > was ran in the modified file case as well and "i" was the only file in the > > working directory before reset. > > > > > I'm assuming then that you mean that some file "m" is modified by the > commit, and do not mean to say that it has local modifications in the > working tree? That is not what I had inferred from earlier, so I was > very much confused. > Yes > In this example, the only file actually checked out is "i", as > everything else will have the skip-worktree bit set..? > Yes > So doing git reset HEAD~1 will reset the branch back one commit, and > now because of this reset is clearing the skip worktree flag, and > since you never had a copy of it checked out it is notified as > deleted, because it's no longer marked as skip-worktree? > Correct > > I think the real fix is to stop having reset clear skip-worktree, no? > > By definition if you do a sparse checkout, you're telling git "I only > care about the files in this sparse checkout, and do not concern me > with anything else"... So the proposed fix is "since git cleared the > skip-worktree flag, we should actually also copy the file out again." > but I think the real problem is that we're clearing skip worktree to > begin with? This certainly is an option but I would have some questions with this approach. Does this statement, "I only care about the files in this sparse checkout, and do not concern me with anything else", mean that git should not change files outside the sparse-checkout whether they are in the working directory or the index? Or does that only apply to the working directory and the index version of files can change to whatever git decides? So in the example above would "m" be the HEAD~1 version of the file in the index or the HEAD version before the reset? Does this apply to all git commands, merge, rebase, cherry-pick, etc? What about when there is a merge conflict with a file that is outside the sparse checkout? Seems to me it is a lot more complex than only caring about the files in the sparse checkout and no concern for anything else. Personally I would like to error on the side of letting the user decide what they want to do, even if that means turning off the skip-worktree bit and putting the working directory into an expected state.