git merge origin / master做什么? [英] what does git merge origin/master do?

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

问题描述

使用 git fetch 从远程获取后,我们需要使用类似于

  git merge origin / master 

我想知道这个命令是否也是 git commit 在同一时间?订单 origin / master 重要吗?我可以写 master / original

解决方案

git merge origin / master 可以做两件事情之一(或错误)。

在第一种情况下,它创建一个新的提交有两个父母:当前 HEAD ,以及ref origin / master 指向的提交(除非你是做一些有趣的事情,这很可能是名为 origin 的远程分支名为 master 的分支(本地指针) ,但这是完全传统的)。



在第二种情况下,如果不需要树级别的合并,而不是创建新的提交,它会更新当前选中的-out指向与 origin / master 指向的提交相同的提交。 (这叫做快进合并 - 当你通过命令行标志进行合并时,git可以直接指向永远或从不这样做)。



它不直接调用 git commit ,这是一个更高级的(git-parlance中的瓷器)命令,面向用户。



调用 git merge master / original 会尝试并解析 master / original code>到一个提交,这几乎可以肯定(再次,除非你有意做)不是 origin / master 。如果您碰巧有名为 master 的远程名为 original 的分支,它将创建一个新的提交,它具有作为第二个父母。



您可能会发现 git help rev-parse 有助于解读git尝试将ref名称或其他符号解析为提交。


After fetching from remote using git fetch, we need to use something like

git merge origin/master

I would like to know if this command also does git commit at the same time? Is the order origin/master important? Can I write master/original?

解决方案

git merge origin/master can do one of two things (or error).

In the first case, it creates a new commit that has two parents: the current HEAD, and the commit pointed to by the ref origin/master (unless you're doing something funny, this is likely to be (the local pointer to) the branch named master on a remote named origin, though this is completely conventional).

In the second case, where there is no tree-level merge necessary, rather than creating a new commit, it updates the currently checked-out ref to point to the same commit as is pointed to by origin/master. (This is called a fast-forward merge -- git can be directed to either always or never do this when you merge through command-line flags).

It does not call git commit directly, which is a higher-level (porcelain in the git-parlance) command intended for users.

Calling git merge master/original will try and resolve master/original to a commit, which will almost certainly (again, unless you've done something deliberate) not be the same as origin/master. If you happen to have a remote named master that has a branch named original, it will create a new commit which has that as the second parent.

You may find git help rev-parse to be helpful in deciphering how git attempts to resolve ref names or other notations into commits.

这篇关于git merge origin / master做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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