在 Git 中,origin/master 与 origin master 之间有什么区别? [英] In Git, what is the difference between origin/master vs origin master?

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

问题描述

我知道,origin 是远程存储库的术语,ma​​ster 是那里的分支.

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

我在这里故意省略了上下文",我希望答案不应该取决于上下文.那么在git命令行中,origin/masterorigin master有什么区别.是否有一种明确的方式来理解何时使用 origin/master 以及何时应该使用 origin master?

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?

推荐答案

这里其实有三件事:origin master 是两个独立的东西,origin/master 是一件事.一共三件事.

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

两个分支:

  • master 是本地分支
  • origin/master 是一个远程分支(它是名为origin"的远程分支上名为master"的分支的本地副本)
  • 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")

一个遥控器:

  • origin 是一个远程
  • origin is a remote

由于origin/master是一个分支,所以可以合并.这里有两个步骤:

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

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

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

然后将 origin/master 合并到 master 中.

Then you merge origin/master into master.

git merge origin/master

然后你可以将你在 master 中的新变化推送回 origin:

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 与 origin master 之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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