git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/2] read-tree: improve untracked file support

From
Duy Nguyen <pclouds@gmail.com>
Date
May 7, 2019, 11:02 UTC
Message-ID
<CACsJy8A+EjymUsSHD8Wj3y3=SfCkaWtfYhjqv+OyaXpkrQXkVg@mail.gmail.com>
In-Reply-To
<994d4687-39ed-91b9-cdf9-d4be39cbb2ba@gmail.com>
On Tue, May 7, 2019 at 5:02 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 12 quoted lines
> > My (biased, obviously) view is that "git reset --hard" is very
> > dangerous and I'm not trying to change that, especially when its
> > behavior has been like this since forever and I'm sure it's used in
> > scripts.
> >
> > Instead "git restore" should be used when you need "git reset --hard
> > HEAD", the most often use case. And since it's new, changing default
> > behavior is not a problem. Which brings us back to git-restore :)
>
> Does restore clean up the branch state like reset? It's tricky because
> you only want to do that if there is no pathspec (or the pathspec is :/
> or equivalent - I can't remember if restore always requires paths or not)

Nope. git-restore cares about files, not branches. Yes git-restore always requires paths, just in case people type "git restore" and expect to see help usage or something.

Show 11 quoted lines
> > But either way, git-restore or git-reset, I still don't see why
> > untracked files are more valuable in this case than tracked ones to
> > change the default.
>
> My issue is that is easy to see what changes you're going to lose in
> tracked files by running diff. For untracked files diff just says a new
> file will be created, it ignores the current contents as the path is in
> the index so it is easy to overwrite changes without realizing. There's
> also a philosophical point that git should not be stomping on paths that
> it is not tracking though that's a bit moot if a path is tracked in one
> revision but not another.

Ah good point about diff. If only we had "git reset --dry-run" (that shows the diff, including untracked files; or perhaps --diff would be a better name for that imaginary option)

-- 
Duy
Previous: Phillip Wood
Message 12 of 12 in “read-tree: improve untracked file support”
  1. 0/2 read-tree: improve untracked file supportPhillip Wood, May 1, 2019
  2. 1/2 read-tree --reset: add --protect-untrackedPhillip Wood, May 1, 2019
  3. Duy NguyenMay 1, 2019
  4. Duy NguyenMay 1, 2019
  5. Duy NguyenMay 2, 2019
  6. Phillip WoodMay 3, 2019
  7. 2/2 read-tree: add --exclude-standardPhillip Wood, May 1, 2019
  8. Duy NguyenMay 1, 2019
  9. Phillip WoodMay 1, 2019
  10. Duy NguyenMay 2, 2019
  11. Phillip WoodMay 7, 2019
  12. Duy NguyenMay 7, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.