git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Help: Trying to setup triangular workflow
@ 2024-01-12  2:23 Matthew B. Gray
  2024-01-12  7:31 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew B. Gray @ 2024-01-12  2:23 UTC (permalink / raw)
  To: git

 Hello

I am trying to set up a triangular workflow against a fork. The example I'm
using is documented here: https://git-scm.com/docs/gitrevisions

Here's the example:

  $ git config push.default current
  $ git config remote.pushdefault myfork
  $ git switch -c mybranch origin/master
  $ git rev-parse --symbolic-full-name @{upstream}
  refs/remotes/origin/master
  $ git rev-parse --symbolic-full-name @{push}
  refs/remotes/myfork/mybranch

My setup looks like this:

  λ git -v
  git version 2.43.0
  λ git remote -vv
  myfork git@github.com:heymatthew/dactyl-configurator-fork (fetch)
  myfork git@github.com:heymatthew/dactyl-configurator-fork (push)
  origin https://github.com/rianadon/dactyl-configurator (fetch)
  origin https://github.com/rianadon/dactyl-configurator (push)

Here's what I get from running the documented example:

  λ git config push.default current
  λ git config remote.pushdefault myfork
  λ git switch -c mybranch origin/main
  λ git push
  * [new branch]          mybranch -> mybranch
  branch 'mybranch' set up to track 'myfork/mybranch'.
  λ git rev-parse --symbolic-full-name @{upstream}
  refs/remotes/myfork/mybranch
  λ git rev-parse --symbolic-full-name @{push}
  refs/remotes/myfork/mybranch

I was expecting @{upstream} to be origin/main, but it appears that @{u} and
@{p} are the same.

Am I doing something wrong?
Are there better examples someone can point me at to do this?

Thanks in advance :)

Ngā mihi,
Matthew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help: Trying to setup triangular workflow
  2024-01-12  2:23 Help: Trying to setup triangular workflow Matthew B. Gray
@ 2024-01-12  7:31 ` Jeff King
  2024-01-13  0:45   ` Matthew B. Gray
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2024-01-12  7:31 UTC (permalink / raw)
  To: Matthew B. Gray; +Cc: git

On Fri, Jan 12, 2024 at 03:23:58PM +1300, Matthew B. Gray wrote:

> Here's what I get from running the documented example:
> 
>   λ git config push.default current
>   λ git config remote.pushdefault myfork
>   λ git switch -c mybranch origin/main
>   λ git push
>   * [new branch]          mybranch -> mybranch
>   branch 'mybranch' set up to track 'myfork/mybranch'.

This push step is rewriting your upstream config. Do you have
push.autoSetupRemote configured? In general you wouldn't want that for a
triangular flow.

Though I think it also is only supposed to kick in if there is no
tracking configured already. Why did the "git switch" invocation not set
up tracking itself? When I run those commands it does. Do you have
branch.autoSetupMerge turned off in your config?

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Help: Trying to setup triangular workflow
  2024-01-12  7:31 ` Jeff King
@ 2024-01-13  0:45   ` Matthew B. Gray
  0 siblings, 0 replies; 3+ messages in thread
From: Matthew B. Gray @ 2024-01-13  0:45 UTC (permalink / raw)
  To: Jeff King; +Cc: git

Hi Peff,

> This push step is rewriting your upstream config. Do you have
> push.autoSetupRemote configured? In general you wouldn't want that for a
> triangular flow.
 
Thanks for the pointer, yes have both push.autoSetupRemote and
branch.autoSetupMerge set. Turning these off has fixed my problem.

With neither option set the example yields:

  @{upstream}: refs/remotes/origin/main
  @{push}: refs/remotes/myfork/mybranch

With push.autosetupremote=true set:

  @{upstream}: refs/remotes/origin/main
  @{push}: refs/remotes/myfork/mybranch

With branch.autoSetupMerge=simple set:

  @{upstream}:
  @{push}: refs/remotes/myfork/mybranch

With branch.autoSetupMerge=simple and push.autosetupremote=true:

  @{upstream}: refs/remotes/myfork/mybranch
  @{push}: refs/remotes/myfork/mybranch

> Though I think it also is only supposed to kick in if there is no
> tracking configured already. Why did the "git switch" invocation not set
> up tracking itself? When I run those commands it does. Do you have
> branch.autoSetupMerge turned off in your config?

If you're interested in looking at my full gitconfig it's hosted here:
https://github.com/heymatthew/dotfiles/blob/trunk/softlinks/.gitconfig

However looks like taking those out of global config has fixed my issue.
Thanks for the help!

Ngā mihi,
Matthew

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-13  0:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12  2:23 Help: Trying to setup triangular workflow Matthew B. Gray
2024-01-12  7:31 ` Jeff King
2024-01-13  0:45   ` Matthew B. Gray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).