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

Re: 'git branch' when origin branch with same name exists

From
Thomas Rast <trast@student.ethz.ch>
Date
Jun 19, 2012, 17:21 UTC
Message-ID
<87a9zztdxt.fsf@thomas.inf.ethz.ch>
In-Reply-To
<4FE091FB.7020202@desrt.ca>
Ryan Lortie <desrt@desrt.ca> writes:
Show 14 quoted lines
> In this case, the user wanted to checkout a branch of a module.  They did:
>
>   git clone git://git.gnome.org/gtk+
>   cd gtk+
>   git branch gtk-3-4
>
> Obviously this is a user error, but it's a pretty innocent one, and
> puts the user in a bad state.  When they figure they should have typed
> "git checkout gtk-3-4" it is already too late -- they will be taken
> onto their locally-created copy of the master branch.
>
> So feature request: 'git branch' should not allow creating a local
> branch that has the same name as a branch that already exists on
> origin' (or any remote?) without some sort of --force flag.

How does this fit with the fact that git has forever(?) created a 'master' branch when cloning, and usually points it at origin/master too?

I honestly haven't decided whether I should like or hate your proposal, but ISTM that outlawing an operation that git does on every clone is a bit moot.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Andreas EricssonNext: Junio C Hamano
Message 10 of 19 in “'git branch' when origin branch with same name exists”
  1. Ryan LortieJun 19, 2012
  2. jaseem abidJun 19, 2012
  3. Michael SchubertJun 19, 2012
  4. Ryan LortieJun 19, 2012
  5. Philippe VaucherJun 19, 2012
  6. Angus HammondJun 19, 2012
  7. Konstantin KhomoutovJun 19, 2012
  8. Ryan LortieJun 19, 2012
  9. Andreas EricssonJun 20, 2012
  10. Thomas RastJun 19, 2012
  11. Junio C HamanoJun 19, 2012
  12. Ryan LortieJun 19, 2012
  13. Junio C HamanoJun 19, 2012
  14. Ryan LortieJun 19, 2012
  15. Phil HordJun 19, 2012
  16. Junio C HamanoJun 20, 2012
  17. Matthieu MoyJun 20, 2012
  18. Junio C HamanoJun 20, 2012
  19. Junio C HamanoJun 19, 2012

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.