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

Re: best git practices, was Re: Git User's Survey 2007 unfinished summary continued

From
Steffen Prohaska <prohaska@zib.de>
Date
Oct 25, 2007, 06:02 UTC
Message-ID
<79366145-3C91-4417-B62C-FFF9EC452076@zib.de>
In-Reply-To
<Pine.LNX.4.64.0710250021430.25221@racer.site>
On Oct 25, 2007, at 1:28 AM, Johannes Schindelin wrote:
Show 26 quoted lines
> On Thu, 25 Oct 2007, Steffen Prohaska wrote:
>
>> On Oct 25, 2007, at 12:14 AM, Johannes Schindelin wrote:
>>
>>> But I think I have to drive my message home again: if what you  
>>> desire
>>> becomes reality, you take away the clear distinction between  
>>> local and
>>> remote branches.  In fact, those branches are neither local (because
>>> the next pull will automatically update them with remote changes,  
>>> but
>>> _only_ if they fast-forward) nor remote (because you plan to work on
>>> them locally).
>>
>> Exactly, because I do not work on those branches alone. These are
>> _shared_ branches. I can work on such a branch with a group of
>> developers. I'm willing to accept this bit of chaos.
>
> It is not just a chaos.  I see a serious problem here.  On _your_
> computer, you do _not_ have a shared branch.  Which is visible  
> _even_ in
> your modified work flow when you have unpushed changes.
>
> So your desired illusion that your local branches are anything but  
> local
> branches will never be perfect enough.

Ok, there is not a fundamental difference between local branches that automatically merge from remotes and local branches that are purely local and _never_ merge anything automatically. Both are only local branches.

But these two types of branches already behave differently when I call "git pull". There is already some kind of "illusion" that some local branches are more tightly connected to remote branches than others.

"git pull" could help to make the illusion even better. The illusion would be better if it was easier to keep the heads of the local branches near to the heads of branches they automatically merge from, as long as this is easily possible.

Show 7 quoted lines
>> Your rebase workflow is not possible if more than one dev wants to  
>> work
>> on the topic branch together.
>
> Why not?  I do it all the time.  CVS users do it all the time, for  
> that
> matter.

You're right. You can rebase your local changes on top of the new shared remote head. And this is probably the best thing you can do to get a clean history. Maybe it should be easier.

So, do I understand correctly, what you propose is:
- never merge but only rebase
- Due to lacking support for this in "git pull", never use
   git pull when working with shared branches but instead _always_ use
   "git fetch; git rebase origin/<branch_I'm_on>".

So you say that one of the first messages in "git for CVS users", "The equivalent of cvs update is git pull origin" [1], is wrong. I don't think I'm able to sell your proposed workflow with the current documentation. But maybe I try if I'm absolutely convinced that it is superior.

[1] http://www.kernel.org/pub/software/scm/git/docs/cvs-migration.html
Show 10 quoted lines
>>> But here is a proposal which should make you and your developers
>>> happy, _and_ should be even easier to explain:
>>>
>>> Work with topic branches.  And when you're done, delete them.
>>
>> Again, if you want to share the topic branch the situation gets
>> more complex.
>
> Hardly so.  In my proposed solution to your problem, there is nothing
> which prevents you from working off of another branch than "master".

Well if you have several local branches checked out that are shared with others you run into the "git push" problem again ... (see below at git push origin master).

Show 14 quoted lines
>>> So the beginning of the day could look like this:
>>>
>>> 	git fetch
>>> 	git checkout -b todays-topic origin/master
>>>
>>> 	[hack hack hack]
>>> 	[test test test]
>>> 	[debug debug debug]
>>> 	[occasionally commit]
>>> 	[occasionally git rebase -i origin/master]
>>>
>>> and the end of the topic
>>>
>>> 	git branch -M master

Isn't this a bit dangerous? It forces to overwrite master no matter what's on it. You don't see diffstats nor a fast forward message that confirms what you're doing.

>>> 	git push origin master

I'd like to see "git push" here. But to make this work without error you'd need to _delete_ master after you pushed. Otherwise it could happen that you later work on a different shared branch and "git push" would complain about master. "git push" would recommend to do a "git pull" and we're back where the discussion started.

Or do you propose to delete master at this point? That is do you propose to _never_ have remote branches checked out locally. Except for a very short period when you do

     git branch -m <shared_branch>
     git push origin <shared_branch>
     git checkout do-not-work-here
     git branch -D <shared_branch>
Show 22 quoted lines
>>> If you should not be ready to push by the end of the day, no need to
>>> worry.  Just stay on that topic branch, and before pushing, do
>>>
>>> 	git fetch
>>> 	git rebase origin/master
>>>
>>> In _every_ case where I explained git, I found that people  
>>> appreciated the
>>> two-step procedures (like you will find in the examples I showed you
>>> above): one git command to work locally, and one to push/fetch to/ 
>>> from
>>> origin.
>>
>> Maybe. I know git quite well now and in a shared workflow "git pull"
>> with auto-fast-forward would help me. I often need to run "for each
>> local branch: git checkout ; git merge" to get rid of the errors
>> reported by "git push".
>
> The problem I see here: you know git quite well.  Others don't, and  
> will
> be mightily confused why pull updates local branches sometimes, and
> sometimes not.

But it already happens now. "git pull" sometimes merges a remote branch (--track) and sometimes it reports an error that is fails to do so (--no-track). It would only do more work automatically in the future and report appropriate warnings or errors if it runs into a problem.

	Steffen
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 83 of 161 in “Re: Git User's Survey 2007 unfinished summary continued”
  1. Jakub NarebskiOct 8, 2007
  2. Git User's Survey 2007 unfinished summary continuedJakub Narebski, Oct 12, 2007
  3. Frank LichtenheldOct 12, 2007
  4. Johannes SchindelinOct 13, 2007
  5. J. Bruce FieldsOct 13, 2007
  6. Shawn O. PearceOct 13, 2007
  7. Frank LichtenheldOct 13, 2007
  8. Johannes SchindelinOct 13, 2007
  9. Andreas EricssonOct 13, 2007
  10. David KastrupOct 13, 2007
  11. J. Bruce FieldsOct 13, 2007
  12. David KastrupOct 13, 2007
  13. Johannes SchindelinOct 14, 2007
  14. Linus TorvaldsOct 14, 2007
  15. Shawn O. PearceOct 14, 2007
  16. Linus TorvaldsOct 14, 2007
  17. david@lang.hmOct 14, 2007
  18. Linus TorvaldsOct 14, 2007
  19. Reece DunnOct 14, 2007
  20. Steven GrimmOct 14, 2007
  21. J. Bruce FieldsOct 14, 2007
  22. Steven GrimmOct 14, 2007
  23. Andreas EricssonOct 14, 2007
  24. Johannes SchindelinOct 14, 2007
  25. Andreas EricssonOct 14, 2007
  26. J. Bruce FieldsOct 14, 2007
  27. Nicolas PitreOct 14, 2007
  28. Shawn O. PearceOct 15, 2007
  29. Nicolas PitreOct 16, 2007
  30. Johannes SchindelinOct 16, 2007
  31. Johannes SchindelinOct 14, 2007
  32. Andreas EricssonOct 14, 2007
  33. David KastrupOct 14, 2007
  34. Jakub NarebskiOct 14, 2007
  35. Johannes SchindelinOct 14, 2007
  36. David KastrupOct 14, 2007
  37. David KastrupOct 14, 2007
  38. Jakub NarebskiOct 14, 2007
  39. Matthew AndrewsOct 14, 2007
  40. David KastrupOct 14, 2007
  41. David TweedOct 14, 2007
  42. Federico Mena QuinteroOct 19, 2007
  43. Jakub NarebskiOct 19, 2007
  44. Johannes SchindelinOct 19, 2007
  45. Federico Mena QuinteroOct 22, 2007
  46. Andreas EricssonOct 20, 2007
  47. Steffen ProhaskaOct 20, 2007
  48. Andreas EricssonOct 20, 2007
  49. Dmitry PotapovOct 21, 2007
  50. Jakub NarebskiOct 20, 2007
  51. Johannes SchindelinOct 20, 2007
  52. Andreas EricssonOct 21, 2007
  53. Johannes SchindelinOct 21, 2007
  54. Andreas EricssonOct 22, 2007
  55. best git practices, was Re: Git User's Survey 2007 unfinished summary continuedJohannes Schindelin, Oct 22, 2007
  56. Andreas EricssonOct 22, 2007
  57. Johannes SchindelinOct 22, 2007
  58. Andreas EricssonOct 22, 2007
  59. Johannes SchindelinOct 22, 2007
  60. Andreas EricssonOct 22, 2007
  61. Steffen ProhaskaOct 22, 2007
  62. Federico Mena QuinteroOct 22, 2007
  63. Johannes SchindelinOct 22, 2007
  64. Carl WorthOct 25, 2007
  65. Jakub NarebskiOct 22, 2007
  66. Steffen ProhaskaOct 23, 2007
  67. Johannes SchindelinOct 23, 2007
  68. Steffen ProhaskaOct 24, 2007
  69. J. Bruce FieldsOct 24, 2007
  70. Andreas EricssonOct 24, 2007
  71. J. Bruce FieldsOct 24, 2007
  72. Steffen ProhaskaOct 24, 2007
  73. J. Bruce FieldsOct 24, 2007
  74. Andreas EricssonOct 24, 2007
  75. J. Bruce FieldsOct 24, 2007
  76. Peter BaumannOct 24, 2007
  77. Steffen ProhaskaOct 24, 2007
  78. Johannes SchindelinOct 24, 2007
  79. Steffen ProhaskaOct 24, 2007
  80. J. Bruce FieldsOct 24, 2007
  81. Steffen ProhaskaOct 24, 2007
  82. Johannes SchindelinOct 24, 2007
  83. Steffen ProhaskaOct 25, 2007
  84. Johannes SchindelinOct 25, 2007
  85. Steffen ProhaskaOct 25, 2007
  86. Andreas EricssonOct 25, 2007
  87. Peter BaumannOct 25, 2007
  88. Andreas EricssonOct 25, 2007
  89. Steffen ProhaskaOct 25, 2007
  90. Johannes SchindelinOct 25, 2007
  91. Andreas EricssonOct 25, 2007
  92. Steffen ProhaskaOct 25, 2007
  93. Johannes SchindelinOct 25, 2007
  94. Theodore TsoOct 25, 2007
  95. Andreas EricssonOct 25, 2007
  96. Theodore TsoOct 25, 2007
  97. Andreas EricssonOct 25, 2007
  98. Junio C HamanoOct 25, 2007
  99. Andreas EricssonOct 25, 2007
  100. Steffen ProhaskaOct 26, 2007
  101. Andreas EricssonOct 26, 2007
  102. Federico Mena QuinteroOct 25, 2007
  103. Mike HommeyOct 25, 2007
  104. J. Bruce FieldsOct 25, 2007
  105. Theodore TsoOct 25, 2007
  106. Andreas EricssonOct 25, 2007
  107. David KastrupOct 26, 2007
  108. Federico Mena QuinteroOct 25, 2007
  109. J. Bruce FieldsOct 25, 2007
  110. Federico Mena QuinteroOct 25, 2007
  111. J. Bruce FieldsOct 25, 2007
  112. Andreas EricssonOct 25, 2007
  113. J. Bruce FieldsOct 25, 2007
  114. David KastrupOct 26, 2007
  115. Make rebase smarterSteven Walter, Oct 26, 2007
  116. Andreas EricssonOct 26, 2007
  117. Johannes SchindelinOct 26, 2007
  118. Junio C HamanoOct 26, 2007
  119. Johannes SchindelinOct 26, 2007
  120. Junio C HamanoOct 26, 2007
  121. Andreas EricssonOct 24, 2007
  122. Johannes SchindelinOct 24, 2007
  123. Andreas EricssonOct 25, 2007
  124. Johannes SchindelinOct 25, 2007
  125. Andreas EricssonOct 25, 2007
  126. Johannes SchindelinOct 25, 2007
  127. Andreas EricssonOct 25, 2007
  128. Karl HasselströmOct 25, 2007
  129. Andreas EricssonOct 25, 2007
  130. Peter BaumannOct 25, 2007
  131. Steffen ProhaskaOct 24, 2007
  132. Andreas EricssonOct 24, 2007
  133. Jakub NarebskiOct 24, 2007
  134. Andreas EricssonOct 25, 2007
  135. Johannes SchindelinOct 25, 2007
  136. Steffen ProhaskaOct 25, 2007
  137. Federico Mena QuinteroOct 25, 2007
  138. Andreas EricssonOct 23, 2007
  139. Daniel BarkalowOct 22, 2007
  140. Wincent ColaiutaOct 22, 2007
  141. David SymondsOct 22, 2007
  142. Johannes SchindelinOct 22, 2007
  143. Robin RosenbergOct 22, 2007
  144. Alex RiesenOct 23, 2007
  145. Nguyen Thai Ngoc DuyOct 22, 2007
  146. Federico Mena QuinteroOct 22, 2007
  147. Jakub NarebskiOct 24, 2007
  148. Karl HasselströmOct 24, 2007
  149. Jakub NarebskiOct 24, 2007
  150. Karl HasselströmOct 24, 2007
  151. Jakub NarebskiOct 24, 2007
  152. Karl HasselströmOct 25, 2007
  153. Catalin MarinasOct 24, 2007
  154. Jakub NarebskiOct 22, 2007
  155. Johannes SchindelinOct 22, 2007
  156. Andreas EricssonOct 22, 2007
  157. Federico Mena QuinteroOct 22, 2007
  158. Jakub NarebskiOct 22, 2007
  159. Steven GrimmOct 22, 2007
  160. J. Bruce FieldsOct 21, 2007
  161. Shawn O. PearceOct 13, 2007

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.