您可以像这样将push.default 设置为当前:
git config push.default current
在man git-config中有描述:
push.default
Defines the action git push should take if no refspec is
explicitly given. Different values are well-suited for
specific workflows; for instance, in a purely central
workflow (i.e. the fetch source is equal to the push
destination), upstream is probably what you want. Possible
values are:
(...)
current - push the current branch to update a branch with the same
name on the receiving end. Works in both central and non-central
workflows.
要检查它在实践中是如何工作的,首先添加一个远程存储库
创建新的本地存储库后将推送到,它甚至可以驻留在
相同的文件系统:
$ git remote add origin <REMOTE_REPO_ADDRESS>
然后尝试git push - 首先使用master 分支,然后使用dev:
$ touch a
$ git add a
$ git commit -minitial
[master (root-commit) c89b8e4] initial
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
$ git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 206 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To /tmp/git-init-remote-
* [new branch] master -> master
$ git checkout -b dev
Switched to a new branch 'dev'
$ touch b
$ git add b
$ git commit -mdev
$ git push
Total 0 (delta 0), reused 0 (delta 0)
To /tmp/git-init-remote-
* [new branch] dev -> dev