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

Re: Question about 'branch -d' safety

From
Will Palmer <wmpalmer@gmail.com>
Date
Jul 11, 2010, 22:02 UTC
Message-ID
<1278885775.2308.27.camel@dreddbeard>
In-Reply-To
<7v1vb9hnd9.fsf@alter.siamese.dyndns.org>
On Sun, 2010-07-11 at 11:41 -0700, Junio C Hamano wrote:
> What problem are you guys really trying to solve?

Almost every porcelain git operation is, in general, "safe". Safety is defined as "will not lose data". I tried to come up with a list of "unsafe" commands recently, and others in #git pointed out that a lot of commands could be made safe by inserting "wait 90 days" into various points. Other than that, there's reset --hard. That's pretty damn safe, in my opinion.

The reflog is the safety-net which allows us to give users help without worrying about (as we might in other VCSs) someone typing a command slightly wrong and blowing away their repository. "Don't worry, you aren't going to break it" is a git truism which helps us to encourage git newbies to experiment a little. Even history rewriting is a "safe" operation.

Personally, I thought "git branch -d" was quite safe enough, as the HEAD reflog would still have a copy of the tip, but as was pointed out to me, this would only be there if the branch in question had been checked-out recently, and of course the reflog for that branch would also be destroyed. I don't really mind the second half of that, but if we're going to solve one problem, why not solve both?

The main thing which is lost when a ref is deleted (assuming no gc,
which doesn't happen during a delete without anything else happening) is
the association between the various objects which will show up during
"git fsck" and the name of the ref which was deleted. Without that loss
of association the conversation can move from:
	"don't panic! If you haven't done anything else yet, you can type "git
fsck" and go through the list of dangling commits one by one until you
find it. Disable automatic garbage collection in the mean-time just to
be safe."
to (wishful thinking):
	"don't panic! try typing "git restore-ref -i" and select the branch you
deleted"

What's really problem I'm really trying to solve? I suppose part is the "I want porcelain commands to be safe, at least for 30 days", and the rest is that I like having more ways to have a conversation which starts off in panic end with "oh, thanks! git is awesome!"

-- 
-- Will
Previous: Jakub NarebskiNext: Clemens Buchacher
Message 16 of 42 in “Question about 'branch -d' safety”
  1. Nanako ShiraishiDec 29, 2009
  2. Nicolas SebrechtDec 29, 2009
  3. Nanako ShiraishiDec 30, 2009
  4. Junio C HamanoDec 30, 2009
  5. Nicolas SebrechtDec 30, 2009
  6. Clemens BuchacherJul 10, 2010
  7. Jonathan NiederJul 10, 2010
  8. Jakub NarebskiJul 10, 2010
  9. Jonathan NiederJul 10, 2010
  10. Clemens BuchacherJul 11, 2010
  11. Jakub NarebskiJul 11, 2010
  12. Julian PhillipsJul 11, 2010
  13. Clemens BuchacherJul 11, 2010
  14. Junio C HamanoJul 11, 2010
  15. Jakub NarebskiJul 11, 2010
  16. Will PalmerJul 11, 2010
  17. Clemens BuchacherJul 12, 2010
  18. Junio C HamanoJul 12, 2010
  19. Clemens BuchacherJul 13, 2010
  20. Will PalmerJul 13, 2010
  21. Johannes SixtJul 13, 2010
  22. Will PalmerJul 13, 2010
  23. Clemens BuchacherJul 13, 2010
  24. Clemens BuchacherJul 17, 2010
  25. Jonathan NiederJul 18, 2010
  26. Jakub NarebskiJul 18, 2010
  27. Will PalmerJul 18, 2010
  28. Jakub NarebskiJul 18, 2010
  29. Will PalmerJul 19, 2010
  30. Jakub NarebskiJul 19, 2010
  31. Joshua JensenJul 19, 2010
  32. Clemens BuchacherJul 19, 2010
  33. Will PalmerJul 19, 2010
  34. Jakub NarebskiJul 19, 2010
  35. Joshua JensenJul 20, 2010
  36. Will PalmerJul 20, 2010
  37. Jakub NarebskiJul 19, 2010
  38. Junio C HamanoJul 19, 2010
  39. Clemens BuchacherJul 19, 2010
  40. Jakub NarebskiJul 19, 2010
  41. Ævar Arnfjörð BjarmasonJul 20, 2010
  42. Matthieu MoyJul 20, 2010

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.