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

Re: [PATCH] cmd_reset: don't trash uncommitted changes unless told to

From
Theodore Tso <tytso@mit.edu>
Date
Jun 25, 2008, 13:51 UTC
Message-ID
<20080625135100.GF20361@mit.edu>
In-Reply-To
<alpine.DEB.1.00.0806251334060.9925@racer>
On Wed, Jun 25, 2008 at 01:38:30PM +0100, Johannes Schindelin wrote:
Show 10 quoted lines
> > $ git config alias.switch checkout
> > $ git switch topic
> > 
> > Hm? Notice that the command even reports back:
> > 
> > Switched to branch "topic"
> > ^^^^^^^^
> 
> Nice.  And now my friend says "why does this braindamaged Git not have 
> that command by _default_?  Hmm?  It is _just as braindamaged_ as CVS!"

I agree that "git switch" would be a great alias to have for "git checkout". It is much more intuitive; traditionally, the issue has always been that it's not so intuitive for existing git users, who have gotten used to the existing quirks, and it people won't want to break things for the existing users. (There are analogues to this is the English language --- why is it that "though", "through", "plough", "cough", "hough", or "tough" don't rhyme[1]?)

[1]  http://www.mipmip.org/tidbits/pronunciation.shtml
> And I would not have anything reasonable for my defense.

Neither does the English language; but just try changing it! "Historical reasons" is for better or for worse a very strong argument.

Show 5 quoted lines
> Because Git _should_ have an intuitive command to switch branches by 
> default.  "git checkout" just does not fly, especially given that it can 
> be used to revert single files (which "git revert" should know how to, but 
> does not, see 
> http://mid.gmane.org/7vlk8wshii.fsf@gitster.siamese.dyndns.org).

I used to argue for this, but gave up, because no one seemed to agree with me. So now I just have the following in /home/tytso/bin/git-revert-file and I am very happy:

#!/bin/sh # prefix=$(git rev-parse --show-prefix)

for i in $*
do
        git show HEAD:$prefix$i > $i
done

It makes "git revert-file <file1> <file2> <file3>" do the right thing. Yeah, it doesn't do enough error checking, and it doesn't handle filenames with spaces, and there are probably other corner cases it doesn't get right, but it's been enough to keep me happy. :-)

If someone wants to take the above and turn it into git-rename.sh and try to submit it to the git tree --- they are welcome to do it. Or heck, if Junio is willing to commit that it that with the appropriate cleanups it would be accepted, I'd be willing to do the work. I just got tired of arguing that the concept of "git revert-file" was in fact useful, and so its existence could be justified, which IIRC was disputed the last time we went around this topic. I know I wanted it, though, so I implemented it for myself.

> I _do_ see a cause of confusion here, _even_ if I know Git pretty well.

As do I.... I think the expert git users have just leared how to work around it, either by learning the non-linearities in the UI, or by our own private hacks or aliases.

						- Ted
Previous: Johannes SchindelinNext: Junio C Hamano
Message 68 of 100 in “Re: why is git destructive by default? (i suggest it not be!)”
  1. David JeskeJun 24, 2008
  2. Nicolas PitreJun 24, 2008
  3. David JeskeJun 24, 2008
  4. David JeskeAug 14, 2016
  5. Lea WiemannJun 24, 2008
  6. Nicolas PitreJun 24, 2008
  7. David JeskeJun 24, 2008
  8. David JeskeAug 14, 2016
  9. Jan KrügerJun 24, 2008
  10. Avery PennarunJun 24, 2008
  11. David JeskeJun 24, 2008
  12. Jakub NarebskiJun 24, 2008
  13. David JeskeJun 24, 2008
  14. David JeskeAug 14, 2016
  15. Jakub NarebskiJun 24, 2008
  16. David JeskeJun 24, 2008
  17. Rogan DawesJun 24, 2008
  18. Johannes GilgerJun 24, 2008
  19. Rogan DawesJun 24, 2008
  20. Jakub NarebskiJun 24, 2008
  21. David JeskeAug 14, 2016
  22. Jakub NarebskiJun 24, 2008
  23. David JeskeAug 14, 2016
  24. Jeff KingJun 24, 2008
  25. David JeskeJun 24, 2008
  26. David JeskeAug 14, 2016
  27. Jeff KingJun 24, 2008
  28. David JeskeJun 24, 2008
  29. Jakub NarebskiJun 24, 2008
  30. David JeskeAug 14, 2016
  31. Fedor SergeevJun 24, 2008
  32. David JeskeJun 24, 2008
  33. Theodore TsoJun 24, 2008
  34. Junio C HamanoJun 27, 2008
  35. しらいしななこJun 28, 2008
  36. しらいしななこJun 28, 2008
  37. Junio C HamanoJun 29, 2008
  38. David JeskeAug 14, 2016
  39. Boaz HarroshJun 24, 2008
  40. Boaz HarroshJun 24, 2008
  41. Jakub NarebskiJun 24, 2008
  42. David JeskeJun 24, 2008
  43. Boaz HarroshJun 25, 2008
  44. David JeskeAug 14, 2016
  45. Brandon CaseyJun 24, 2008
  46. David JeskeJun 24, 2008
  47. Theodore TsoJun 24, 2008
  48. Junio C HamanoJun 24, 2008
  49. Theodore TsoJun 25, 2008
  50. Jakub NarebskiJun 25, 2008
  51. Junio C HamanoJun 25, 2008
  52. Brandon CaseyJun 26, 2008
  53. David JeskeAug 14, 2016
  54. Steven WalterJun 24, 2008
  55. cmd_reset: don't trash uncommitted changes unless told toSteven Walter, Jun 24, 2008
  56. Junio C HamanoJun 24, 2008
  57. Boaz HarroshJun 25, 2008
  58. Junio C HamanoJun 25, 2008
  59. Boaz HarroshJun 25, 2008
  60. Johannes SchindelinJun 25, 2008
  61. Matthias KestenholzJun 25, 2008
  62. Anton GladkovJun 25, 2008
  63. Johannes SchindelinJun 25, 2008
  64. Craig L. ChingJun 25, 2008
  65. Anton GladkovJun 25, 2008
  66. Johannes SixtJun 25, 2008
  67. Johannes SchindelinJun 25, 2008
  68. Theodore TsoJun 25, 2008
  69. Junio C HamanoJun 25, 2008
  70. Theodore TsoJun 25, 2008
  71. Avery PennarunJun 25, 2008
  72. Junio C HamanoJun 25, 2008
  73. Avery PennarunJun 25, 2008
  74. Junio C HamanoJun 25, 2008
  75. Avery PennarunJun 25, 2008
  76. Re* [PATCH] cmd_reset: don't trash uncommitted changes unless told toJunio C Hamano, Jun 25, 2008
  77. Junio C HamanoJun 25, 2008
  78. Junio C HamanoJun 26, 2008
  79. Steven WalterJun 25, 2008
  80. Theodore TsoJun 25, 2008
  81. Junio C HamanoJun 25, 2008
  82. Theodore TsoJun 25, 2008
  83. Junio C HamanoJun 25, 2008
  84. Junio C HamanoJun 26, 2008
  85. Petr BaudisJun 25, 2008
  86. Johannes SchindelinJun 26, 2008
  87. Junio C HamanoJun 25, 2008
  88. Björn SteinbrinkJun 26, 2008
  89. Johannes SchindelinJun 26, 2008
  90. Björn SteinbrinkJun 26, 2008
  91. Avery PennarunJun 26, 2008
  92. Johannes SchindelinJun 26, 2008
  93. Matthieu MoyJun 26, 2008
  94. Johannes SchindelinJun 26, 2008
  95. David KastrupJun 26, 2008
  96. Ian HiltJun 25, 2008
  97. Andreas EricssonJun 26, 2008
  98. Jon LoeligerJun 26, 2008
  99. Johannes GilgerJun 25, 2008
  100. Brandon CaseyJun 24, 2008

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.