简体   繁体   English

origin / branch_name和branch_name之间的区别?

[英]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: 你必须记住有不同类型的分支:

  • (Purely) local branches, ie 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 . 您可能知道远程名称下的远程存储库,例如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; 也简单地称为远程分支 ,如在Pro Git书中 ,但我发现这句话令人困惑; 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; 这里, 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/mybranchmybranch可能会有所不同。

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是远程计算机上的分支
  • just 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.

相关问题 git checkout有什么区别 <branch_name> 和git checkout -b <branch_name> - Is there any difference between git checkout <branch_name> and git checkout -b <branch_name> git中&#39;:&#39;的用法是什么 <branch_name> : <branch_name> - what is use of ':' in git <branch_name>:<branch_name> git 日志:commit 是什么意思... → (origin/branch_name) ← - git log: what is meaning of commit ... → (origin/branch_name) ← `git branch -f之间的区别 <branch_name><hash> `和`git checkout <branch_name> ; git reset --hard <hash> `在干净的工作树下? - Difference between `git branch -f <branch_name> <hash>` and `git checkout <branch_name>; git reset --hard <hash>` under a clean working tree? “$ git push”branch_name 的致命错误 - fatal error with “$ git push ”branch_name" Git 结帐<branch_name>不管用</branch_name> - Git checkout <branch_name> is not working 同时为 `git push -u origin $BRANCH_NAME` 和 `git push` 设置一个更快的别名 - Set up a quicker alias for `git push -u origin $BRANCH_NAME` and `git push` at the same time Git致命:模糊参数&#39;branch_name&#39;:修订版和文件名 - Git fatal: ambiguous argument 'branch_name': both revision and filename 可以在 Jenkins 管道中提取 $BRANCH_NAME 字符串的一部分吗? - Possible to extract part of $BRANCH_NAME string in Jenkins Pipeline? 致命:含糊不清的说法&#39; <branch_name> &#39;:修订版和文件名 - Fatal: ambiguous argument '<branch_name>': both revision and filename
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM