简体   繁体   English

Git,推向远程

[英]Git, pushing to remote

Lets suppose i am in a local ABC with branches branch_A and branch_B . 假设我在本地ABC中,分支为branch_Abranch_B

From repo_A , what are the differences between: repo_A ,有什么区别:

 - git push origin
 - git push origin branch_A
 - git push origin branch_A:branch_A

The reason for question is the following sequence of events, i find to be surprising: 问题的原因是以下一系列事件,我感到很惊讶:

11:05:56 ~/blah $ git push origin
Counting objects: 31, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (17/17), 1.28 KiB, done.
Total 17 (delta 10), reused 0 (delta 0)
To ssh://git@mygit/myrepo.git
   141fc0d..d42c3b6  branch_B -> branch_B    // While i was in branch_A

11:06:02 ~/blah $ git branch
  branch_A
* branch_B 

The default behaviour of behaviour of git push origin (if you haven't customized the config option push.default ) is to push all "matching" branches. git push origin行为的默认行为(如果您尚未自定义config选项push.default )是推送所有“匹配”的分支。 That means that each local branch is pushed to one with the same name in origin so long as a branch with that name already exists in origin . 这意味着只要本地已有一个具有该名称的分支,就将每个本地分支推送到一个具有相同名称的分支 In this case, it seems that you have a branch_B branch in origin as well as locally. 在这种情况下,您似乎在origin以及本地都具有branch_B分支。

The two other variants you quoted: 您引用的其他两个变体:

git push origin branch_A
git push origin branch_A:branch_A

.... are actually equivalent - if you don't include the : in the refspec to separate the source name from the destination name, it assumes that you mean the same name in the source and destination. ....实际上是等效的-如果您在refspec中不包含:来将源名称与目标名称分开,则假定您在源和目标中使用相同的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM