如何从多个提交中推送多个分支? [英] How to push multiple branches from multiple commits?
问题描述
我从来没有在 GitHub
之前使用 git
发布了Windows应用程序,所以我从未在命令行中使用它。
所以这是我的情况:
我在 master
上做了一些提交,然后切换分支,并在那里做了一些提交。没有推到GitHub。
当我在Windows应用程序(我假设 git push
)中点击 sync
时,我惊讶的是,所有的提交都被推送到了我的新分支 - 甚至是我在 master
中进行的提交。
<由于这是Windows应用程序的行为,我想我必须使用命令行。
什么是正确的
git push
命令推送提交到远程正确的分支?要推送所有分支(参考refs /头),使用以下命令(其中origin是您的远程):
git push origin --all
您也可以设定 push.default
至匹配
配置默认推送两端都具有相同名称的所有分支。例如:
git config --global push.default matching
因为Git 2.0的默认值是 simple
这是最安全的选项。
I never used git
before GitHub
released the Windows app, so I've never used it in command line.
So here's my situation:
I did some commits on master
, then switched branch and did some commits there too. All without pushing to GitHub.
When I then clicked sync
in the the windows app (which I assume does git push
), to my surprise, all my commits were pushed to my new branch - even the commits I made while I was in master
.
Since this is the behavior of the windows app, I guess I have to use the command line.
What is the correct git push
command to push the commits to the correct branches on the remote?
To push all branches (refs under refs/heads), use the following command (where origin is your remote):
git push origin --all
You can also set push.default
to matching
in your config to push all branches having the same name on both ends by default. For example:
git config --global push.default matching
Since Git 2.0 the default is simple
which is the the safest option.
这篇关于如何从多个提交中推送多个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!