I regularly read the git blog and release notes, but did not see mention of this new feature in either. I was pleasantly surprised when I saw this tweet from James Ide:
With the newest version of Git 2.37.0, you can run just "git push" to push new branches. No more "--set-upstream origin". Enable with:— James Ide (@JI) July 12, 2022
git config --global --add --bool push.autoSetupRemote true pic.twitter.com/1SzIqzvEFR
This may be minor as it saves only a few keystrokes. (Less than it
--set-upstream can be abbreviated as
-u.) But, I do
it many times a day and almost always forget to do it the first time so
I bet its impact will be significant. I see almost no reason not to do
git config --global --add --bool push.autoSetupRemote true.
The git manual describes the option, and the use case is detailed in the original email and actual commit.
At the risk of repeating what James wrote, this is what happens before the feature was implemented.
moonstone:~/www.oasys.net/(main=)$ git --version git version 2.36.1 hub version refs/heads/master moonstone:~/www.oasys.net/(main=)$ git cob testautoremote Switched to a new branch 'testautoremote' moonstone:~/www.oasys.net/(testautoremote)$ git push fatal: The current branch testautoremote has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin testautoremote
brew update git,
--set-upstream is no longer needed,
and git does what is expected.
moonstone:~/www.oasys.net/(testautoremote)$ git --version git version 2.37.0 hub version refs/heads/master moonstone:~/www.oasys.net/(testautoremote)$ git push Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 remote: remote: Create a pull request for 'testautoremote' on GitHub by visiting: remote: https://github.com/oasys/www.oasys.net/pull/new/testautoremote remote: To github.com:oasys/www.oasys.net.git * [new branch] testautoremote -> testautoremote branch 'testautoremote' set up to track 'origin/testautoremote'.
Here’s the relevant section of
[push] default = simple autoSetupRemote = true