All of lore.kernel.org
 help / color / mirror / Atom feed
From: <rsbecker@nexbridge.com>
To: <crstml@libero.it>, "'Andreas Schwab'" <schwab@linux-m68k.org>
Cc: <git@vger.kernel.org>
Subject: RE: connecting the local main branch to the remote origin/main without pushing
Date: Sun, 29 Dec 2024 09:39:58 -0500	[thread overview]
Message-ID: <030601db59ff$8c966280$a5c32780$@nexbridge.com> (raw)
In-Reply-To: <5dfb85a8-2e26-92f8-e3f9-5e3fb89ca43a@libero.it>

On December 29, 2024 5:02 AM, crstml@libero.it wrote:
>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.


  reply	other threads:[~2024-12-29 14:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-28 15:47 connecting the local main branch to the remote origin/main without pushing crstml
2024-12-28 16:11 ` rsbecker
2024-12-29  9:01   ` crstml
2024-12-28 17:15 ` Andreas Schwab
2024-12-28 17:20   ` Junio C Hamano
2024-12-28 19:08   ` Jeff King
2024-12-28 19:39     ` Andreas Schwab
2024-12-29 10:01   ` crstml
2024-12-29 14:39     ` rsbecker [this message]
2024-12-29 10:03   ` crstml

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='030601db59ff$8c966280$a5c32780$@nexbridge.com' \
    --to=rsbecker@nexbridge.com \
    --cc=crstml@libero.it \
    --cc=git@vger.kernel.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.