本文介绍了在Git中,origin / master vs origin master有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道, origin 是远程存储库的一个术语, master 是分支。

我故意忽略这里的背景,我希望答案不应该取决于背景。所以在git命令行中, origin / master origin master 有什么区别。是否有一种非模糊的方式来了解何时使用 origin / master 以及何时使用原始主人

origin master 是两件独立的事情, origin / master 是一回事。共有三件事。



两个分支:


  • master 是一个本地分支

  • origin / master 是一个远程分支(它是一个远程名为origin的分支名为master的本地副本



  • 一个远程:

    >


    • origin 是一个远程



    示例:分两步拉



    因为 origin / master 是一个分支,你可以合并它。这里有两步:

    第一步,从远程原点获取 master 。将获取 origin 上的 master 分支,并将本地副本命名为 origin / master

      git fetch origin master 

    然后,将 origin / master 合并到 master 中。

      git merge origin / master 

    然后,您可以将 master 中的新更改推回到 origin

      git push origin master 



    更多示例



    您可以按名称获取多个分支...

      git fetch origin master stable oldstable 

    您可以合并多个分支... p>

      git merge origin / master hotfix-2275 hotfix-2276 hotfix-2290 


    I know, origin is a term for the remote repository and master is the branch there.

    I am purposely omitting the "context" here and I am hoping that the answer should not depend upon the context. So in git command lines, what is the difference between origin/master and origin master. Is there a non-ambiguous way to understand when to use origin/master and when I should use origin master?

    解决方案

    There are actually three things here: origin master is two separate things, and origin/master is one thing. Three things total.

    Two branches:

    • master is a local branch
    • origin/master is a remote branch (which is a local copy of the branch named "master" on the remote named "origin")

    One remote:

    • origin is a remote

    Example: pull in two steps

    Since origin/master is a branch, you can merge it. Here's a pull in two steps:

    Step one, fetch master from the remote origin. The master branch on origin will be fetched and the local copy will be named origin/master.

    git fetch origin master
    

    Then you merge origin/master into master.

    git merge origin/master
    

    Then you can push your new changes in master back to origin:

    git push origin master
    

    More examples

    You can fetch multiple branches by name...

    git fetch origin master stable oldstable
    

    You can merge multiple branches...

    git merge origin/master hotfix-2275 hotfix-2276 hotfix-2290
    

    这篇关于在Git中,origin / master vs origin master有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    09-04 20:12