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

Re: Difficulties in advertising a new branch to git newbies

From
JWJosef Weidendorfer <josef.weidendorfer@gmx.de>
Date
Feb 1, 2007, 00:20 UTC
Message-ID
<200702010120.58806.Josef.Weidendorfer@gmx.de>
In-Reply-To
<871wlbascq.wl%cworth@cworth.org>
On Wednesday 31 January 2007, Carl Worth wrote:
> > It would be nice if:
> >
> > git clone -b ${branch} git://...
Nice indeed.

Additionally, it would be nice for clone to directly checkout tags. Why not an option "--checkout <ref>" to directly checkout <ref> after cloning?

This goes nicely with the "-b" option to create a new branch. A "-b <branch>" option alone would imply "--checkout origin/<branch>". And without "--checkout" or "-b" option it defaults to "-b master" which gives exactly the same behavior as now.

This way,
 git clone --checkout v1.0 git://...
would checkout tag v1.0, and use a detached head for it.
> In addition, it would be great to have a command that did the same
> setup within an existing repository.

Why not use "git clone" for this? Currently, the man page says about the directory it will clone into:

 "Cloning into an existing directory is not allowed."

But we could relax this: if the specified directory is the root of a checkout (ie. with a .git subdir), we would clone a remote repository into the same local repository. However, this should not default to "-b master", ie. not switch the current branch. Additionally, the remote name should not default to "origin", but to the "humanish" part of the source repository. IMHO we should have done the latter since long time ago, as a remote "origin" is not really useful once you work with branches from multiple remote repositories.

Doing this,
 git clone git://... <newdir>
would be the equivalent of
 mkdir <newdir>
 cd <newdir>
 git init
 git clone -b master git://... .
which IMHO would make a lot of sense.
 
> And I would be most happy if the two commands for these two use cases
> shared as much syntax as possible, so I could publish one string and
> users could cut-and-paste it to either command as appropriate.
You would say:
"To get version <xyz>, do a
  git clone --checkout <xyz> git://...

If you already have a local clone of the repository, append the directory of your local repository as target to clone this version into".

> One string I would have liked would have been "git://... ${branch}"

IMHO "-b" option is better as it tells you that it creates a new local development branch for you.

Josef
Show 7 quoted lines
> but existing git-clone and git-fetch command syntax is not too
> amenable for that, (git-clone interprets an argument after the URL as
> the name of the local directory to create while git-fetch interprets
> the argument after the URL as a refspec).
> 
> -Carl
> 
Previous: Carl WorthNext: Santi Béjar
Message 36 of 50 in “Difficulties in advertising a new branch to git newbies”
  1. Carl WorthJan 30, 2007
  2. Jakub NarebskiJan 30, 2007
  3. Yann DirsonJan 30, 2007
  4. Jakub NarebskiJan 30, 2007
  5. Junio C HamanoJan 30, 2007
  6. Jakub NarebskiJan 30, 2007
  7. Matthias LederhoferJan 30, 2007
  8. Matthias LederhoferJan 30, 2007
  9. Jeff KingJan 30, 2007
  10. Junio C HamanoJan 31, 2007
  11. Nicolas PitreJan 31, 2007
  12. Jeff KingJan 31, 2007
  13. Nicolas PitreJan 31, 2007
  14. Jeff KingJan 31, 2007
  15. Nicolas PitreJan 31, 2007
  16. Jeff KingJan 31, 2007
  17. Junio C HamanoJan 31, 2007
  18. Theodore TsoJan 31, 2007
  19. Junio C HamanoJan 31, 2007
  20. Jakub NarebskiJan 31, 2007
  21. Nicolas PitreJan 31, 2007
  22. Daniel BarkalowJan 31, 2007
  23. Nicolas PitreJan 31, 2007
  24. Daniel BarkalowJan 31, 2007
  25. Nicolas PitreJan 31, 2007
  26. J. Bruce FieldsJan 31, 2007
  27. Jakub NarebskiJan 31, 2007
  28. Nicolas PitreJan 31, 2007
  29. Daniel BarkalowJan 31, 2007
  30. Nicolas PitreJan 31, 2007
  31. Guilhem BonnefilleJan 31, 2007
  32. Carl WorthJan 31, 2007
  33. Johannes SchindelinJan 31, 2007
  34. Santi BéjarJan 31, 2007
  35. Carl WorthJan 31, 2007
  36. Josef WeidendorferFeb 1, 2007
  37. Santi BéjarFeb 1, 2007
  38. Jakub NarebskiFeb 1, 2007
  39. Carl WorthFeb 6, 2007
  40. Junio C HamanoFeb 6, 2007
  41. Junio C HamanoFeb 6, 2007
  42. Jeff KingFeb 6, 2007
  43. Carl WorthFeb 6, 2007
  44. Junio C HamanoFeb 6, 2007
  45. Carl WorthFeb 6, 2007
  46. Jakub NarebskiFeb 6, 2007
  47. Jeff KingFeb 6, 2007
  48. Junio C HamanoFeb 6, 2007
  49. Jeff KingFeb 6, 2007
  50. Nicolas PitreFeb 6, 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.