-1

I do not want to type git branch --set-upstream-to=origin/<branch> myBranchName.

I tried

[push]
    default = current

but it works only for push, not for pull, [pull] do nothing.

Also tried

[branch]
    autosetupmerge = always
    autosetuprebase = always

My git version is 2.35 (current stable in Gentoo) so push.autoSetupRemote is unavailable for me. Only custom aliases, no simple config option?

Vitaly Zdanevich
  • 13,032
  • 8
  • 47
  • 81

2 Answers2

0

I'm on an ancient 2.24 and use push.default=current in my config.

[push]
        default = current

Also, even without this you don't need to type the set-upstream command. git push should type it for you and then you can just copy/paste it.

For example:

❯ git push
fatal: The current branch feature/test has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin feature/test

(select and right click here)
❯  git push --set-upstream origin feature/tm/test

tymtam
  • 31,798
  • 8
  • 86
  • 126
0

branch.autosetupmerge=always is almost certainly not what you want; it will cause all new branches you create to use their source as the upstream - even if you branch from another local branch.

As of git 2.37+, you probably want to set these two things:

git config --global branch.autoSetupMerge simple: This will set up the upstream automatically, but only if the new local branch name matches the remote branch name.

git config --global push.autoSetupRemote true: This will automatically set up tracking when you push new branches - it also makes git push "just work" for new branches.

Tao
  • 13,457
  • 7
  • 65
  • 76