From: Philip Oakley Date: Thu, 27 Apr 2017 22:07:57 GMT Subject: Re: Submodule/contents conflict Message-ID: In-Reply-To: From: "Junio C Hamano" Sent: Wednesday, April 26, 2017 3:51 AM > "Philip Oakley" writes: > >> As I recall Christoph was using checkout to copy a file (e.g. a >> template file) from an older commit/revision into his worktree, and >> was suprised that this (git checkout ) also _staged_ the >> file, rather than simply letting it be in a modified/untracked state. > > This probably is taking it even further than the original topic, but > I raise this weather-balloon to see if anybody is interested. > > In the modern day, it might be useful if the "--working-tree-only" > mode added a new file as an intent-to-add entry to the index, but > that is not what "git apply (no other options)" (which is the gold did you mean `git add` ? Or am I missing something. > standard for command that operates on the working tree and/or on the > index) does, so it is not done in this patch. IOW, if you grab a > path that does not exist in your index out of , you will > write out an untracked file to the working tree. It sound like a good idea, as I wasn't aware of another easy way of doing it. > > -- >8 -- > Subject: [PATCH] checkout: add --working-tree-only option > > "git checkout " has always copied the blob from > the tree-ish to the index before checking them out to the working tree. > > Some users may want to grab a blob out of a tree-ish directly to the > working tree, without updating the index, so that "git diff" can be > used to assess the damage and adjust the file contents taken from a > different branch to be more appropriate for the current branch. > > The new option "--working-tree-only" allows exactly that. > > In the hindsight, when a command works on the working tree and/or > the index, the usual convention is: > > - with no other option, the command works only on the working tree; > > - with "--cached" option, the command works only on the index; and > > - with "--index" option, the command works on both the working tree > and the index. > > So we probably should have triggered the default behaviour under the > "--index" option, and triggered this "--working-tree-only" mode of > behaviour when "--index" option is not given. From the same point > of view, "git checkout --cached " would have > done the same as "git reset " would do. And > that may have made the command set a bit more consistent. > > But that is merely a hindsight being 20/20, oh well. > > Signed-off-by: Junio C Hamano > --- > Documentation/git-checkout.txt | 22 +++++++++++++++------- > builtin/checkout.c | 10 +++++++++- > t/t2022-checkout-paths.sh | 21 +++++++++++++++++++++ > 3 files changed, 45 insertions(+), 8 deletions(-) > > diff --git a/Documentation/git-checkout.txt > b/Documentation/git-checkout.txt > index 8e2c0662dd..201677752e 100644 > --- a/Documentation/git-checkout.txt > +++ b/Documentation/git-checkout.txt > @@ -14,6 +14,7 @@ SYNOPSIS > 'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] ] > [] > 'git checkout' [-f|--ours|--theirs|-m|--conflict=