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

Re: [PATCH 0/2] git-gui: revert untracked files by deleting them

From
Pratyush Yadav <me@yadavpratyush.com>
Date
Nov 3, 2019, 01:12 UTC
Message-ID
<20191103011225.b6emr2ldskktokgd@yadavpratyush.com>
In-Reply-To
<CAPSOpYufF8B0sBUUYqBx5YTxH+02qRom+tz4a0_2iBcNOvvMXA@mail.gmail.com>
On 30/10/19 12:16PM, Jonathan Gilbert wrote:
Show 11 quoted lines
> On Wed, Oct 30, 2019 at 4:09 AM Bert Wesarg
> bert.wesarg-at-googlemail.com |GitHub Public/Example Allow|
> <xlwsizdz58ciy7t@sneakemail.com> wrote:
> > in Git speak, that operation is called 'clean' (see 'git clean') why
> > should we overload the 'revert' operation here?
> 
> It's less about overloading the 'revert' operation as overloading the
> UI action which is currently called "Revert". I think it would be a
> worse experience to have to activate a different option to remove
> unwanted files as to remove unwanted changes. Maybe the UI option
> could be renamed "Revert & Clean" or something?

I disagree. There are valid workflows where you want to remove all changes to tracked files, but leave untracked ones alone. As an example, say you wrote a small script to fix some textual things, like your variable re-name patch. Now you run a diff before you commit those changes just to be sure, and notice that your script was overzealous and made some changes it shouldn't have. So, you clean up all tracked files, and give your script a fresh start. Here, you don't want to delete your script.

And in the other direction, say you want to delete all untracked files 
but have unstaged changes in your tracked files. Combining "Revert" and 
"Clean" does not give you an option to only delete untracked files. So 
you now either have to stash your changes, or run `git clean` from the 
command line.
 
> As a side note, `git clean untracked-file` won't do anything with a
> default configuration, you have to explicitly `-f` it. Not sure if
> that's relevant, but it does feel like a higher barrier to entry than
> `git revert`.

`git revert` is different from our "Revert", though I admit the naming is quite confusing. `git revert` creates a new commit that "reverses" the changes made in an earlier commit(s). The important point to note here is that `git revert` is used when you publish some commits, and then realise later they had some bugs. Now you can't just drop those commits because that would re-write the history, and it would change all the commit hashes since that commit. So, you use `git revert` to create a new commit that _textually_ reverses those changes. The buggy commit still exists in the tree, but its changes don't.

In contrast, git-gui's "Revert" works on unstaged changes. It does not create a new commit. In fact, our revert does something similar to `git checkout -- <file>` (it uses `git checkout-index` to be precise).

So I don't think you should, or _can_, use `git revert` for what you want to do. And so, I don't see why it is being factored in with this discussion. Am I missing something?

-- 
Regards,
Pratyush Yadav
Previous: Jonathan GilbertNext: Jonathan Gilbert
Message 10 of 57 in “git-gui: revert untracked files by deleting them”
  1. 0/2 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Oct 30, 2019
  2. 1/2 git-gui: consolidate naming conventionsJonathan Gilbert via GitGitGadget, Oct 30, 2019
  3. Pratyush YadavNov 3, 2019
  4. 2/2 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Oct 30, 2019
  5. Pratyush YadavNov 3, 2019
  6. Jonathan GilbertNov 4, 2019
  7. Jonathan GilbertNov 4, 2019
  8. Bert WesargOct 30, 2019
  9. Jonathan GilbertOct 30, 2019
  10. Pratyush YadavNov 3, 2019
  11. Jonathan GilbertNov 3, 2019
  12. Pratyush YadavNov 3, 2019
  13. 0/2 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 7, 2019
  14. 1/2 git-gui: consolidate naming conventionsJonathan Gilbert via GitGitGadget, Nov 7, 2019
  15. 2/2 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 7, 2019
  16. Pratyush YadavNov 11, 2019
  17. Jonathan GilbertNov 11, 2019
  18. Philip OakleyNov 11, 2019
  19. Jonathan GilbertNov 12, 2019
  20. Philip OakleyNov 12, 2019
  21. Jonathan GilbertNov 12, 2019
  22. Philip OakleyNov 26, 2019
  23. Pratyush YadavNov 12, 2019
  24. Pratyush YadavNov 11, 2019
  25. 0/2 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 13, 2019
  26. 2/2 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 13, 2019
  27. Pratyush YadavNov 16, 2019
  28. Jonathan GilbertNov 16, 2019
  29. 1/2 git-gui: consolidate naming conventionsJonathan Gilbert via GitGitGadget, Nov 13, 2019
  30. 0/2 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 17, 2019
  31. 1/2 git-gui: consolidate naming conventionsJonathan Gilbert via GitGitGadget, Nov 17, 2019
  32. 2/2 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 17, 2019
  33. Pratyush YadavNov 24, 2019
  34. Pratyush YadavNov 19, 2019
  35. Jonathan GilbertNov 19, 2019
  36. 0/3 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 24, 2019
  37. 1/3 git-gui: consolidate naming conventionsJonathan Gilbert via GitGitGadget, Nov 24, 2019
  38. 2/3 git-gui: update status bar to track operationsJonathan Gilbert via GitGitGadget, Nov 24, 2019
  39. Pratyush YadavNov 27, 2019
  40. Jonathan GilbertNov 28, 2019
  41. 3/3 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 24, 2019
  42. Pratyush YadavNov 27, 2019
  43. 0/3 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 28, 2019
  44. 1/3 git-gui: consolidate naming conventionsJonathan Gilbert via GitGitGadget, Nov 28, 2019
  45. 2/3 git-gui: update status bar to track operationsJonathan Gilbert via GitGitGadget, Nov 28, 2019
  46. Pratyush YadavNov 30, 2019
  47. Jonathan GilbertDec 1, 2019
  48. Philip OakleyDec 1, 2019
  49. Jonathan GilbertDec 1, 2019
  50. 3/3 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Nov 28, 2019
  51. 0/3 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Dec 1, 2019
  52. 1/3 git-gui: consolidate naming conventionsJonathan Gilbert via GitGitGadget, Dec 1, 2019
  53. 3/3 git-gui: revert untracked files by deleting themJonathan Gilbert via GitGitGadget, Dec 1, 2019
  54. 2/3 git-gui: update status bar to track operationsJonathan Gilbert via GitGitGadget, Dec 1, 2019
  55. Benjamin PoirierFeb 26, 2020
  56. Pratyush YadavMar 2, 2020
  57. Pratyush YadavDec 5, 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.