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
Theodore Tso <tytso@mit.edu>
Date
Oct 25, 2007, 13:24 UTC
Message-ID
<20071025132401.GA22103@thunk.org>
In-Reply-To
<472070E5.4090303@op5.se>
On Thu, Oct 25, 2007 at 12:33:09PM +0200, Andreas Ericsson wrote:
> Because it's convenient, ofcourse. Don't you have 'maint', 'next'
> and 'master' in your clone of git.git? I'm guessing at least 99% of
> the people on this list have those branches lying around in their
> clones, even if they only ever use 'next' and/or 'master'.

I find it just as easy to say: "git checkout origin/maint" or "git checkout origin/next" when I want to examine some other branch.

If I want to make a change against maint, then I follow up "git checkout origin/maint" with a "git checkout -b <topic-name>". Part of the reason though, why I *want* to keep the topic branch around is precisely because I don't get to push to the central repository. So I want to keep it around so either (a) the central maintainer can pull from me, and I delete it only after he's done the pull, or (b) so I can use git-chery so I can see when patches that I created and sent via git-format-patch and git-send-email have been accepted.

You're using a diferent workflow, and with users who aren't interested in learning the fine points of git. But main issue is that git isn't optimized for what you want to do. So I can suggest a couple of different approaches. One is to simply do things the 'hg' way. Explicitly set up different repos for the different branches. It's more inefficient, but it does work. And if the bulk of your users are, ah, "aggressive ignorant" about git --- and many developers don't care about learning the fine points of their tools, and a successful software company needs to learn how to leverage the skills of such mid-level engineers (only at a startup or if you are at Google can you insist only only hiring the best and brightest) --- then it might be that the 'hg' approach is easier. Certainly that was the approach Larry McVoy has always used with BitKeeper, and he is focused on meeting the needs of his corporate customers.

Another would be to set up a wrapper script for "git-clone" that creates a separate local working directory for each branch. So for example, it might do something like this:

#!/bin/sh
# Usage: get-repo <URL> [dir]
URL=$1
dir=$2
branches=`git-ls-remote --heads $URL | sed -e 's;.*/;;'`
if [ "$dir"x = "x" ]; then dir=`basename $URL`; fi
git clone $URL .temp-repo
mkdir $dir
cd $dir
for i in $branches; do
    mkdir $i
    cd $i
    git init
    git remote add -t $i origin $URL
    echo ref: refs/heads/$i > .git/HEAD
    git fetch ../../.temp-repo refs/remotes/origin/$i:refs/remotes/origin/$i
    # do it a second time to get the tags (bug in fetch?)
    git fetch ../../.temp-repo refs/remotes/origin/$i:refs/remotes/origin/$i
    git merge origin/$i
    git config remote.origin.push $i:$i
    cd ..
done
cd ..
rm -rf .temp-repo

For bonus points, this script could be made smarter so that each of the branches shared a common git object database, and some error checking would be nice, but hopefully this gets the basic idea across.

This way, the "basic git users" get a separate working directory for each branch, where "git pull" updates that particular branch, and "git push" updates changes to the remote branch.

Does this do what you want?
							- Ted

P.S. Note by the way that if you are having everyone own access to push into a single central repository, having a "next" branch probably doesn't make seense. You're probably way better off just simply having "master" (which would be your devel branch), and "maint" for bug fixes.

Previous: Johannes SchindelinNext: Andreas Ericsson
Message 94 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.