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

Re: why is git destructive by default? (i suggest it not be!)

From
DJDavid Jeske <jeske@google.com>
Date
Aug 14, 2016, 00:45 UTC
Message-ID
<willow-jeske-01l5izRzFEDjCdyL>
In-Reply-To
<32541b130806232220r292d691cn5bf5f9976126aa29@mail.gmail.com>
Thanks for all the helpful responses...
-- Avery Pennarun wrote:
Show 6 quoted lines
> git's philosophy is different. Branches are really just "temporary
> tags". A merge operation doesn't just copy data from one branch to
> another: it actually joins the two histories together, so you can then
> trace back through the exact history of the merged branches, commit by
> commit. "git log" will show each checkin to *either* branch
> individually, instead of just one big "merge" checkin.

If branches are "temporary tags" how do I see the actual code they had working in their branch before they merged it?

I'm reading about rebase, and it sounds like something I would want to forever disallow on my git repository, because it looks like it rewrites history and makes it impossible to get to the state of the tree they actually had working before the merge. However, something you say below both clarifies and confuses this.

Am I understanding this wrong?
> The end result is that even if you delete the source branch after
> doing a merge, nothing is actually lost.

..and what if you never merge? That branch-pointer points to useful information about a development attempt, but it was never merged. (imagine a different development path was taken) They never created a tag because it's not clear when that work was "done" (unlike a release, which is much more well understood). What prevents someone from deleting the branch-pointer or moving it to a different part of the tree, causing that set of changes to be a dangling ref lost in a sea of refs. Later when someone goes back looking for it, how would they ever find it in a sea of tens of thousands of checkins?

> Thus, there's no reason for git to try to make branches impossible
> to lose, as they are in svn.

Before I set the GC times to "100 years", there was a HUGE reason for git to make those branch-pointers impossible to lose, because by default if you lose them git actually garbage collects them and throws the diffs away after 90 days!

Show 5 quoted lines
> Another way to think of it is that svn's concept of a "branch" is
> actually the "reflog" in git. (svn records which data a particular
> branch name points to over time, just like git's reflog does.) git
> branches are something else entirely; a git branch always points at
> only a single commit, and has no history of its own.

That's sort of helpful, and sort of confusing. I think of git's branches as "branch pointers to the head of a linked-list of states of the tree".

As long as you keep those refs without deleting them, and you keep that branch pointer to the head, you can walk back through the history of that branch. If multiple developers are working in the branch (and not using rebase, and not garbage collecting), can't you even go track down the working state of their local clients while they were working before they merged?

If I'm understanding all that right, it's exactly the kind of functionality I want -- the ability to reproduce the state of all working history, exactly as it was when the code was actually working in someone's client a long time ago, before they merged it to the mainline. Except the standard model seems to be to let the system "garbage collect" all that history, and toss it away as unimportant -- and in some cases it seems to even provide developers with ways to more aggressively assure garbage collection makes it disappear.

Am I expecting too much out of git? It doesn't really feel like a source control system for an organization that wants to save everything, forever, even when those people and trees and home directories disappear. It feels like a distributed patch manager that is much more automatic than sending around diffs, but isn't overly concerned with providing access to old history. (which, duh, is no surprise given that's what I expect it's doing for linux kernel)

Previous: Jakub NarebskiNext: Jeff King
Message 23 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.