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

Re: Proposal: create meaningful aliases for git reset's hard/soft/mixed

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Nov 23, 2011, 08:49 UTC
Message-ID
<vpq4nxvusty.fsf@bauges.imag.fr>
In-Reply-To
<CAGK7Mr4GZq5eXn4OB+B0ZborX-OVoXiWU8Lo1XM5LRZDuRe1YA@mail.gmail.com>
Philippe Vaucher <philippe.vaucher@gmail.com> writes:
> A lot of time when I want to use reset for smth else than "--hard" I
> have to go and look the documentation.

I have to agree with this, I took a lot of time to understand/memorize the meaning of reset options.

> Optional: a new mode would be introduced for consistency:
> --worktree (or maybe --tree): only updates the worktree but not the index
That would be an alias for "git checkout <rev> -- path", right?

I don't really like this "there is more than one way to do it" in Git's command-line, I think we should think very carefully before introducing yet another instance of it.

> --keep could be removed in favor of an additional --safe flag

If you are to change the option names, then you should also make the behavior safe by default:

* "git reset --all" = "git reset --keep"
* "git reset --all --force" = "git reset --hard"

With the current terminology, --hard has the advantage that it makes it realatively clear how dangerous it is. Still, I've seen users losing data because they did a "git reset --hard" with uncommited changes. Git is safe by default most of the time, and "git reset --hard" is one unfortunate exception (because it was there before --keep, people are more used to it).

"git reset --all" would make it worse, because the option name is less scary, people would be less reluctant to use it, and would get more chance to lose data.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Philippe VaucherNext: Philippe Vaucher
Message 2 of 22 in “Proposal: create meaningful aliases for git reset's hard/soft/mixed”
  1. Philippe VaucherNov 23, 2011
  2. Matthieu MoyNov 23, 2011
  3. Philippe VaucherNov 23, 2011
  4. Martin von ZweigbergkDec 18, 2012
  5. Nguyen Thai Ngoc DuyNov 23, 2011
  6. Junio C HamanoNov 23, 2011
  7. Philippe VaucherNov 23, 2011
  8. Phil HordDec 1, 2011
  9. Thomas RastDec 2, 2011
  10. Miles BaderDec 2, 2011
  11. Phil HordDec 2, 2011
  12. Philippe VaucherDec 2, 2011
  13. Phil HordDec 2, 2011
  14. Philippe VaucherDec 6, 2011
  15. Phil HordOct 3, 2012
  16. Junio C HamanoOct 3, 2012
  17. Junio C HamanoOct 3, 2012
  18. Jan EngelhardtDec 15, 2012
  19. Phil HordDec 1, 2011
  20. Martin von ZweigbergkDec 18, 2012
  21. Junio C HamanoDec 18, 2012
  22. Jeff KingDec 18, 2012

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.