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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 20, 2012, 18:07 UTC
Message-ID
<7v62alx3ev.fsf@alter.siamese.dyndns.org>
In-Reply-To
<vpqa9zxan3a.fsf@bauges.imag.fr>
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
Show 22 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Requiring starting point and failing without --force will never
>> happen, but it could be a possible approach to issue an additional
>> advice message under reasonably narrow conditions, namely:
>>
>>  - The starting point was not given explicitly;
>>
>>  - It would have DWIMed to "git checkout -t -b it origin/it" when
>>    creating the branch (I think you need to check configurations
>>    like branch.autosetupmerge and existence of the tracking branch
>>    remotes/origin/it); and
>>
>>  - advice.branchNotTrackingCorrespondingRemote is not set to false.
>
> I like that. Stg like
>
> $ git branch next
> Creating local branch next starting from <sha1>.
> If you meant to checkout a new branch 'next' to track remote branch
> 'next' from 'origin', run these commands now:
> git branch -d next; git checkout next
Oh, another precondition would be that --force was _not_ given.

It is fairly clear "git branch -f next" is asking to forcibly update an existing local 'next' to the current HEAD, not to origin/next, and giving the above suggestion will be mildly irritating in such a case.

Previous: Matthieu MoyNext: Junio C Hamano
Message 18 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.