Git config autoSetupRemote
在最新版的 Git 2.37.0 中,开启如下配置项后就能直接 git push 新分支,不再需要 --set-upstream origin
git config --global --add --bool push.autoSetupRemote true
旧版本:
$ git push
fatal: The current branch example has no upstream branch.
To push the current branch and set the remote as upstream, use
git push--set-upstream origin example
新版本开启配置后:
$ git push
Total 0 (delta 0),reused 0 (delta 0),pack-reused 0
remote:
remote: Create a pull request for example' on GitHub by visiting:
remote: https://github.com/you/repo/pull/new/example
remote:
To github.com:you/repo.git
* [new branch] example -> example
branch'example' set up to track 'origin/example' by rebasing