origin / branch_name和branch_name之间的区别? [英] difference between origin/branch_name and branch_name?

查看:144
本文介绍了origin / branch_name和branch_name之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

推送到bitbucket。

如果我这样做: git push origin origin / branch_name 我的提交不是

pre $ code>总共0(delta 0),重用0(delta 0)

如果我做了 git push origin branch_name 我的提交被推送:

 计数对象:160,完成。 
使用多达8个线程的增量压缩。
压缩对象:100%(13/13),完成。
写作对象:100%(20/20),2.10 KiB | 0字节/秒,完成。
总计20(delta 6),重用0(delta 0)

那么什么是来源/意思在branch_name前面?为什么它很重要?

解决方案

你必须记住有不同类型的分支:


  • (纯粹)本地分支,即您承诺的分支

  • 分支住在远程存储库中,因为缺乏更好的术语。您可以使用远程名称知道远程存储库,例如 origin 。然而,从存储库的角度来看,这样一个分支是 local 。欢迎使用分布式版本控制! :)

  • 远程追踪分支。也简称为远程分支机构,如 Pro Git book ,但我觉得这句话很混乱; 远程追踪分支更准确。他们是特殊的本地分支,其唯一目的是反映您最后一次与服务器通信时存在于远程存储库中的分支的状态。特别是,你不能提交这种类型的分支。



这里, branch_name 是一个 local 分支,而 origin / branch_name 是一个远程跟踪分支;它反映了居住在原点 中的相应分支的状态。



运行

  git fetch 

远程跟踪分支 origin / master 和相应的分支,位于原始 应完全同步(当然,模并发推送到远程服务器)。那么,应该不会感到意外的是,

  git push origin origin / branch_name 

不会推送任何东西:您基本上试图推送已存在于相应的分支的祖先中的东西在 origin

中。

然而,如果你的 local code> branch_name ,超前于一个或多个提交,


然后运行

  git push origin branch_name 

会将包含在 branch_name 但不在位于原点分支中:


for pushing to bitbucket.

If I do: git push origin origin/branch_name my commits are not pushed.

Total 0 (delta 0), reused 0 (delta 0)

If I do git push origin branch_name my commits are pushed:

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? And why does it matter?

解决方案

You have to remember that there are different types of branches:

  • (Purely) local branches, i.e. branches you commit to,
  • Branches that live in a remote repository, for lack of a better term. You may know the remote repository in question under a remote name, such as origin. From that repository's point of view, though, such a branch is local. Welcome to Distributed Version Control! :)
  • Remote-tracking branches. Also simply called remote branches, as in the Pro Git book, but I find this phrase confusing; remote-tracking branch is more accurate. They're special local branches whose sole purpose is to reflect the state of branches that live in a remote repository at the time of your last communication with the server. In particular, you can't commit to branches of this type.

Here, branch_name is a local branch, whereas origin/branch_name is a remote-tracking branch; it reflects the state of the corresponding branch that lives in 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). 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 .

However, if your local branch, branch_name, is ahead by one or more commits,

then running

git push origin branch_name

will push the commits contained in branch_name but not in the branch that live in origin:

这篇关于origin / branch_name和branch_name之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆