Libon

Git config autoSetupRemote

0Mins #shell
在 Git 中直接 push, 而不用附带参数

在最新版的 Git 2.37.0 中,开启如下配置项后就能直接 git push 新分支,不再需要 --set-upstream origin

Terminal window
1
git config --global --add --bool push.autoSetupRemote true

旧版本:

Terminal window
1
$ git push
2
fatal: The current branch example has no upstream branch.
3
To push the current branch and set the remote as upstream, use
4
5
git push--set-upstream origin example

新版本开启配置后:

Terminal window
1
$ git push
2
Total 0 (delta 0),reused 0 (delta 0),pack-reused 0
3
remote:
4
remote: Create a pull request for example' on GitHub by visiting:
5
remote: https://github.com/you/repo/pull/new/example
6
remote:
7
To github.com:you/repo.git
8
* [new branch] example -> example
9
branch'example' set up to track 'origin/example' by rebasing

CD ..
回顾上一篇
CSS 网格背景