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

RE: connecting the local main branch to the remote origin/main without pushing

From
rsbecker@nexbridge.com <rsbecker@nexbridge.com>
Date
Dec 29, 2024, 14:39 UTC
Message-ID
<030601db59ff$8c966280$a5c32780$@nexbridge.com>
In-Reply-To
<5dfb85a8-2e26-92f8-e3f9-5e3fb89ca43a@libero.it>
On December 29, 2024 5:02 AM, crstml@libero.it wrote:
Show 33 quoted lines
>Andreas Schwab wrote:
>> On Dez 28 2024, crstml@libero.it wrote:
>>
>>> My question is:
>>>       Is it possible when applying the method 2 to have (without pushing)
>>>       the local main branch connected to the remote origin/main branch as
>>>       in the case of method 1 which by cloning connects these branches.
>>
>> You can establish the effect by setting two config entries:
>>
>> $ git config branch.main.remote origin $ git config branch.main.merge
>> refs/heads/main
>>
>
>Indeed.
>
>By making a diff between a folder containing a cloned empty repository (method 1)
>and an empty folder in which "git init" and "git remote" were run (method 2) the
>only difference is in the .git/config file. In the cloned version the file contains the
>following section:
>
>[branch "main"]
>         remote = origin
>         merge = refs/heads/main
>
>These commands add exactly this section to the file.
>
>"git branch -u" does exactly the same thing when connecting a local branch to an
>existing remote branch. It adds this section. "git push ---set-upstream"
>also does the same thing.
>
>It would be nice if "git branch -u" would work for an empty remote repository and
>allow us to set the upstream branch.
It might be a useful contribution to make git branch --force -u understand this.
Previous: crstml@libero.itNext: crstml@libero.it
Message 9 of 10 in “connecting the local main branch to the remote origin/main without pushing”
  1. crstml@libero.itDec 28, 2024
  2. rsbecker@nexbridge.comDec 28, 2024
  3. crstml@libero.itDec 29, 2024
  4. Andreas SchwabDec 28, 2024
  5. Junio C HamanoDec 28, 2024
  6. Jeff KingDec 28, 2024
  7. Andreas SchwabDec 28, 2024
  8. crstml@libero.itDec 29, 2024
  9. rsbecker@nexbridge.comDec 29, 2024
  10. crstml@libero.itDec 29, 2024

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.