Automatically track remote branch with git

As of git 2.37.0, this is now possible with git configuration.

Run to update your configuration:

git config --global --add --bool push.autoSetupRemote true

Then git push will automatically setup the remote branch.

Note: The --global flag means this will apply to all git commands on your machine (regardless of which repo it is), you can omit the flag to make it specific to a single repo on your machine.

Documentation:

https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushautoSetupRemote

push.autoSetupRemote

If set to “true” assume –set-upstream on default push when no upstream tracking exists for the current branch; this option takes effect with push.default options simple, upstream, and current. It is useful if by default you want new branches to be pushed to the default remote (like the behavior of push.default=current) and you also want the upstream tracking to be set. Workflows most likely to benefit from this option are simple central workflows where all branches are expected to have the same name on the remote.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)