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

Re: [PATCH 1/1] config: support setting up a remote tracking branch upon creation

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 28, 2021, 17:48 UTC
Message-ID
<xmqqim0u9vnb.fsf@gitster.g>
In-Reply-To
<20210728135041.501850-2-mathstuf@gmail.com>
Ben Boeckel <mathstuf@gmail.com> writes:
> The `branch.autoSetupMerge` works well for setting up tracking a local
> branch, but there is no mechanism to automatically set up a remote
> tracking situation.

This description is probably insufficient to explain what's missing, probably because "set up a remote tracking situation" is a bit fuzzy.

Without this patch, I can do this already:
    $ git checkout -t -b topic origin/topic
And after the above, we have
    [branch "topic"]
	remote = origin
	merge = refs/heads/topic
Of course, you can instead use a short-hand DWIM, e.g.
    $ git checkout topic ;# assuming origin/topic exists

gives us the same thing. In either case, topic knows to integrate with the 'topic' branch from remote 'origin' and push back there.

So instead of saying "there is no mechanism to ...", be a bit more specific what you can and cannot do in this first paragraph.

Then we can describe the solution we'd propose in the second and subsequent paragraphs.

Thanks.
> +branch.defaultRemote::
> +	When a new branch is created with 'git branch', 'git switch' or 'git
> +	checkout', this value will be used to initialize the
> +	"branch.<name>.remote" setting.

You mean without "-t"? I offhand do not think of a reason why this is a good idea. How would one create local topic branches that you plan to merge locally into your own larger topic branch to be shared with others? Shouldn't there be an easy way to countermand the setting by this configuration?

> +branch.defaultPushRemote::
> +	When a new branch is created with 'git branch', 'git switch' or 'git
> +	checkout', this value will be used to initialize the
> +	"branch.<name>.pushRemote" setting.
Ditto.
> +branch.defaultMerge::
> +	When a new branch is created with 'git branch', 'git switch' or 'git
> +	checkout', this value will be used to initialize the
> +	"branch.<name>.merge" setting.

So the expected use case is to fork multiple local branches, to integrate with the same branch from the remote? I think we can already do

    $ git checkout -t -b xyzzy origin/master
    $ git checkout -t -b frotz origin/master

and you can lose -t with branch.autosetupmerge setting. As the "git branch" command needs to get the name of your branch (e.g. 'xyzzy' or 'frotz') and which remote tracking branch you start from (e.g. 'origin/master'), even with branch.{defaultRemote,defaultMerge} configuration, you wouldn't lose that many keystrokes, I suspect.

Or do you plan to make
    $ git branch xyzzy
a short-hand for
    $ git branch -t xyzzy origin/master

when defaultRemote and defaultMerge are set to 'origin' and 'refs/heads/master'? It would be way too confusing to start the new branch from origin/master in such a case, as everybody learned that "git branch xyzzy" that does not say where the branch initially points at uses HEAD.

Previous: Ben BoeckelNext: Ben Boeckel
Message 3 of 20 in “Improve automatic setup of tracking for new branches”
  1. 0/1 Improve automatic setup of tracking for new branchesBen Boeckel, Jul 28, 2021
  2. 1/1 config: support setting up a remote tracking branch upon creationBen Boeckel, Jul 28, 2021
  3. Junio C HamanoJul 28, 2021
  4. Ben BoeckelJul 28, 2021
  5. Junio C HamanoJul 28, 2021
  6. 0/1 Improve automatic setup of tracking for new branchesBen Boeckel, Jul 29, 2021
  7. 1/1 config: support a default remote tracking setup upon branch creationBen Boeckel, Jul 29, 2021
  8. Philippe BlainJul 30, 2021
  9. Ben BoeckelJul 30, 2021
  10. Junio C HamanoJul 30, 2021
  11. Ævar Arnfjörð BjarmasonAug 2, 2021
  12. Ben BoeckelAug 2, 2021
  13. Ævar Arnfjörð BjarmasonAug 2, 2021
  14. Junio C HamanoJul 30, 2021
  15. Ben BoeckelJul 30, 2021
  16. Philippe BlainJul 30, 2021
  17. Ben BoeckelJul 30, 2021
  18. Philippe BlainJul 30, 2021
  19. Ben BoeckelJul 30, 2021
  20. Johannes SchindelinAug 2, 2021

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.