[英]difference between origin/branch_name and branch_name?
for pushing to bitbucket. 推送到bitbucket。
If I do: git push origin origin/branch_name
my commits are not pushed. 如果我这样做: git push origin origin/branch_name
我的提交没有被推送。
Total 0 (delta 0), reused 0 (delta 0)
If I do git push origin branch_name
my commits are pushed: 如果我执行git push origin branch_name
我的提交被推送:
Counting objects: 160, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (20/20), 2.10 KiB | 0 bytes/s, done.
Total 20 (delta 6), reused 0 (delta 0)
so what is the origin/ mean in front of the branch_name? 那么branch_name前面的起源/平均值是多少? And why does it matter? 为什么这很重要?
You have to remember that there are different types of branches: 你必须记住有不同类型的分支:
origin
. 您可能知道远程名称下的远程存储库,例如origin
。 From that repository's point of view, though, such a branch is local . 但是,从该存储库的角度来看,这样的分支是本地的 。 Welcome to Distributed Version Control! 欢迎使用分布式版本控制! :)
Here, branch_name
is a local branch, whereas origin/branch_name
is a remote-tracking branch; 这里, branch_name
是本地分支,而origin/branch_name
是远程跟踪分支; it reflects the state of the corresponding branch that lives in origin
. 它反映了生活在origin
的相应分支的状态。
Right after running 跑完后
git fetch
the remote-tracking branch origin/master
and the corresponding branch that live in origin
should be perfectly in sync (modulo concurrent pushes to the remote server, of course). 远程跟踪分支origin/master
和相应的分支生活在origin
应该是完全同步(模并发推到远程服务器,当然)。 It shouldn't be a surprise, then, that 那么,那应该不足为奇
git push origin origin/branch_name
doesn't push anything: you're essentially attempting to push stuff that is already present in the ancestry of the corresponding branch that live in origin
. 不推什么:你基本上试图推的东西已经存在于生活在相应的分支的祖先origin
。
However, if your local branch, branch_name
, is ahead by one or more commits, 但是,如果您的本地分支branch_name
提前一个或多个提交,
then running 然后跑
git push origin branch_name
will push the commits contained in branch_name
but not in the branch that live in origin
: 将推包含在提交branch_name
但不能在分支生活在origin
:
using a graphical tree viewer (like gitk --all
) will show you, that origin/mybranch
and mybranch
might differ. 使用图形树查看器(如gitk --all
)将显示, origin/mybranch
和mybranch
可能会有所不同。
origin
is just the default name for a cloned remote , which (in your case) contains a branch mybranch
(just like your local repository) origin
只是克隆远程的默认名称,(在您的情况下)包含分支mybranch
(就像您的本地存储库一样)
so when you ask to push origin/mybranch
to origin
, you are synchronizing the origin
remote with itself, hence it doesn't do anything (luckily the remote is always in synch with itself). 因此,当您要求将origin/mybranch
推送到origin
,您正在将origin
遥控器与其自身同步,因此它不会执行任何操作(幸运的是, 遥控器始终与其自身同步)。
the name origin
is arbitrary, and could have been set with the --origin
flag when cloning. 名称origin
是任意的,并且在克隆时可以使用--origin
标志进行设置。
origin/branch_name
is a branch on the remote machine origin/branch_name
是远程计算机上的分支 branch_name
is a branch on the local machine just branch_name
是本地计算机上的分支 origin is whats stored remotely on github 原点是什么是远程存储在github上
without origin is what is stored locally on your computer 没有原点是您的计算机本地存储的内容
when you commit 1st you are commit locally to your computer 当您提交1st时,您将在本地提交到您的计算机
when you push origin branch name you are pushing to github 当你推动原始分支名称时,你正在推动github
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.