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

Re: Suggestion: make git checkout safer

From
EAEd Avis <eda@waniasset.com>
Date
Jun 4, 2015, 11:00 UTC
Message-ID
<loom.20150604T124827-124@post.gmane.org>
In-Reply-To
<20150603194756.GB29730@vps892.directvps.nl>
Kevin Daudt <me <at> ikke.info> writes:
>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 don't quite agree; you only learn to use the -f flag if the plain command doesn't do what you want. With rm, I want to remove that file, dammit! The -f flag is often a necessity to stop the tool getting in my way. But when fixing up a working tree, I rarely want to silently trash any local changes.

>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.
Well that's not quite the flavour given by the documentation, which says
    >Updates files in the working tree to match...

'Updating' files sounds like a fairly safe thing to do, right? Like 'cvs update' or 'svn update', which don't just overwrite working tree changes. The doc doesn't really make clear that any local changes will be discarded; indeed the only mention of that is

       -f, --force
         When switching branches... this is used to throw away local changes.

To the casual reader, following 'the exception proves the rule', it appears that local changes are not thrown away except in this case.

-- 
Ed Avis <eda@waniasset.com>
Previous: Kevin DaudtNext: Torsten Bögershausen
Message 15 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.