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

Re: Suggestion: make git checkout safer

From
Kevin Daudt <me@ikke.info>
Date
Jun 3, 2015, 19:47 UTC
Message-ID
<20150603194756.GB29730@vps892.directvps.nl>
In-Reply-To
<loom.20150603T114527-151@post.gmane.org>
On Wed, Jun 03, 2015 at 09:55:05AM +0000, Ed Avis wrote:
> Jeff King <peff <at> peff.net> writes:
> 
Show 7 quoted lines
> If my personal experience is anything to go by, newcomers may fall into the
> habit of running 'git checkout .' to restore missing files.  In the old days
> I would often delete a file and then run 'cvs update' or 'svn update' to
> restore it.  That would fetch a fresh copy from the repository, and while
> it might do some kind of diff/patch operation on modified files, it would
> not simply throw away local changes.
> 

The problem with these kinds of habbits is that they easily extend to the --force variant. If people execute git checkout . as a habbit without thinking, they will soon train to do git checkout -f . without thinking, and then you still have the same problem.

I do share your sentiment that it's easy to loose uncomitted changes to git checkout <path>, but like Jeff said, the entire goal of this command is to reset specific files from the index or commits.

Introducing a way to undo this would be a much better option to me then adding an extra switch with no way to undo.

Previous: Torsten BögershausenNext: Ed Avis
Message 14 of 28 in “Suggestion: make git checkout safer”
  1. Ed AvisJun 3, 2015
  2. Jeff KingJun 3, 2015
  3. Ed AvisJun 3, 2015
  4. Jeff KingJun 3, 2015
  5. Ed AvisJun 3, 2015
  6. Junio C HamanoJun 3, 2015
  7. Randall S. BeckerJun 3, 2015
  8. Junio C HamanoJun 3, 2015
  9. Randall S. BeckerJun 3, 2015
  10. Stefan BellerJun 3, 2015
  11. Ed AvisJun 4, 2015
  12. Ed AvisJun 4, 2015
  13. Torsten BögershausenJun 3, 2015
  14. Kevin DaudtJun 3, 2015
  15. Ed AvisJun 4, 2015
  16. Torsten BögershausenJun 4, 2015
  17. Ed AvisJun 5, 2015
  18. Duy NguyenJun 5, 2015
  19. Eric SunshineJun 5, 2015
  20. Junio C HamanoJun 5, 2015
  21. Ed AvisJun 5, 2015
  22. Eric SunshineJun 5, 2015
  23. Philip OakleyJun 3, 2015
  24. Junio C HamanoJun 3, 2015
  25. Jeff KingJun 3, 2015
  26. Randall S. BeckerJun 3, 2015
  27. Junio C HamanoJun 3, 2015
  28. John SzakmeisterJun 4, 2015

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.