当我在开发分支做git pull origin master时会发生什么? [英] What happens when I do git pull origin master in the develop branch?

查看:207
本文介绍了当我在开发分支做git pull origin master时会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



什么是 git pull origin master c $ c> do?



从本地开发的远程主机中获取所有东西并合并它?取消本地master分支中的所有内容并合并它?



有没有办法从开发中更新master git checkout master 第一个?

解决方案

git pull origin master 从远程调用原点分支到您当前的分支。它只会影响你当前的分支,而不会影响你当地的主分支。 它会给你看起来像这样的历史:

   -  x  -  x  -  x  -  x(develop)
\ /
x - x - x(origin / master )

您的本地主分支与此无关。 git pull 基本上是 git fetch git merge ;它会获取远程分支,然后将其合并到当前分支中。这是一个像任何其他合并;它不会做任何不可思议的事情。



如果您想更新您的本地主分支,您别无选择,只能查看它。合并到未检出的分支是不可能的,因为Git需要一个工作树才能执行合并。 (尤其是,为了报告合并冲突并让你解决它们是绝对必要的。)



如果你碰巧知道,转发(即你没有在本地主分支不提交在原产地的主)提交你可以解决,在这个答案中描述


Let's say I have a private topic branch called develop with 2 commits ahead of master.

What does git pull origin master do?

Pull everything from the remote master in the local develop and merge it? Pull everything in the local master branch and merge it?

And is there a way to update master from develop without git checkout master first?

解决方案

git pull origin master pulls the master branch from the remote called origin into your current branch. It only affects your current branch, not your local master branch.

It'll give you history looking something like this:

- x - x - x - x (develop)
   \         /
    x - x - x (origin/master)

Your local master branch is irrelevant in this. git pull is essentially a combination of git fetch and git merge; it fetches the remote branch then merges it into your current branch. It's a merge like any other; it doesn't do anything magical.

If you want to update your local master branch, you have no choice but to check it out. It's impossible to merge into a branch that's not checked out, because Git needs a work tree in order to perform the merge. (In particular, it's absolutely necessary in order to report merge conflicts and allow you to resolve them.)

If you happen to know that pulling into master would be a fast-forward (i.e. you have no commits in your local master branch that aren't in origin's master) you can work around, as described in this answer.

这篇关于当我在开发分支做git pull origin master时会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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