如何设置 git 从当前分支推送和拉取?
所以我的仓库中有两个跟踪分支,“testing”和“master”。这些正在跟踪我的远程服务器上相同的命名分支。我将 Push.default 的 .gitconfig 选项设置为“跟踪”。然而,当我执行“git Push origin”时,它将我的新更改与远程服务器上的主分支合并。这是“git Remote show origin”的输出:
* remote origin
Fetch URL: git+ssh://******************
Push URL: git+ssh://******************
HEAD branch: master
Remote branches:
master tracked
testing tracked
Local refs configured for 'git push':
master pushes to master (up to date)
testing pushes to testing (fast-forwardable)`
基本上,我希望能够仅键入“git Push”和“git pull”,它会自动使用适当的分支推送和拉取到原点。
编辑:
[*****]$ git config push.default
tracking
[*****]$ git --version
git version 1.7.3.4
So I have two tracked branches in my repo, 'testing' and 'master'. These are tracking to the same named branches on my remote server. I have the .gitconfig option for push.default set to 'tracking'. However when I do "git push origin" it merges my new changes with the Master branch ont he remote server. Here is the output of 'git remote show origin':
* remote origin
Fetch URL: git+ssh://******************
Push URL: git+ssh://******************
HEAD branch: master
Remote branches:
master tracked
testing tracked
Local refs configured for 'git push':
master pushes to master (up to date)
testing pushes to testing (fast-forwardable)`
Basically, I want to be able to just type 'git push' and 'git pull' and it will automatically push and pull to origin with the appropriate branch.
EDIT:
[*****]$ git config push.default
tracking
[*****]$ git --version
git version 1.7.3.4
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅
git Push
的文档 (这位于示例部分的底部)。See the documentation for
git push
(this was in towards the bottom in the examples section).您可以通过编辑“push.default”属性来更改此行为。
我总是使用“简单”模式,尝试找到与当前分支同名的远程分支并推送到它。
由于其易用性和安全性,建议初学者使用此模式。
在官方文档(页面末尾)中查找更多信息: http://git-scm.com/文档/git-config
You can change this behavior by editing the "push.default" property.
I always use the "simple" mode which tries to find a remote branch having the same name as your current branch and push to it.
This is the mode advised for beginners due to his ease of use and safety.
Find more in the official doc (end of the page): http://git-scm.com/docs/git-config