我搜索了一下,但似乎找不到答案。
在我可以访问的两个盒子上,当我执行“git push --dry-run origin mytestbranch”时,我得到以下结果:
To [email protected] /cdn-cgi/l/email-protection:rien/test.git
* [new branch] test -> test
然而,在我的 MacBook 上,当我尝试相同的命令时,我得到以下结果:
To [email protected] /cdn-cgi/l/email-protection:rien/test.git
417248a..cf7d564 test -> master
仅当我明确地说推送到测试原始分支时(git push --dry-run origin test:test
)是否按预期工作。
我如何改变它,以便基本git push --dry-run bb test
会推送到新创建的远程分支而不是 master 吗?
我在两个盒子上创建了测试分支git checkout -b test origin/master
编辑添加:
- 两个分支都有一个git config push.default
set to tracking
.
我特别想知道如何配置 git 以便当我输入时git push origin test
它的作用与git push origin test:test
检查是否有差异推动政策 https://stackoverflow.com/a/21772695/6309:
git config push.default
我怀疑第一个盒子上的推送很“简单”
git config push.default simple
还检查上游分支 https://stackoverflow.com/a/6244487/6309第二个分支上的测试分支:
git config branch.test.merge
在第二个分支上,它可能未定义(因此默认值为 master)
You 可以明确设置 https://stackoverflow.com/a/2286030/6309:
git checkout test
git branch -u origin/test
# or
git push -u origin test:test
The OP rien https://stackoverflow.com/users/4331302/rien adds 在评论中 https://stackoverflow.com/questions/27329500/git-push-origin-branchname-always-pushes-to-master/27329538?noredirect=1#comment43127662_27329538:
在注意到我对这些盒子有不同版本的 git 后,我又查看了一下,发现如果我设置push.default
to simple
or matching
对于 git 版本 1.9.3,git push origin test
按预期工作。
似乎是tracking
push.default
此版本的 git 已弃用,因此它无法理解它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)