Git pull rebase - 它是什么rebasing [英] Git pull rebase - What is it rebasing

查看:197
本文介绍了Git pull rebase - 它是什么rebasing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍然没有得到git pull --rebase发生的事情。我理解重新定义的概念,并且在我自己的本地未发布的分支中使用它,从未在我的分支已经在远程发布时发布。我听说过使用远程进行rebase的危险,并且看着git pull --rebase,我不太清楚这是安全的还是不安全的。



说例如我正在MyBranch分支上工作,并将它推送到远程,以便它被存储在除我自己的本地机器以外的其他地方(并且可能其他人将合并我的更改以保持开发同步)。

  a  -  b  -  c  -  d  -  g  -  h(master,origin / master)

e - f - i(MyBranch,origin / MyBranch)

说我做了一些本地开发

  a  -  b  -  c  -  d  -  g  -  h(master ,原产地/主人)
\
e - f - i(origin / MyBranch) - j - k - l(MyBranch)



说别人更新了MyBranch,并将其发展成为主人。

  a  -  b  -  c  -  d  -  g  -  h(master,origin / master)
\\\
e - f - i-- -m(origin / MyBranch)
\
j - k - l(MyBranch)

如果我通过拉动git pull --rebase进行更新,我的树会如何看起来像?它只会重写j,k,l(那些本地的)的历史,并将其放在m的顶部,还是会重写已经在远程分支上的其他历史记录?



到底是什么样的rebase起点和哪个是重播?



另外,如果origin / MyBranch被合并到其他上游分支中,如develop,那么我的rebase有什么影响?

  a  -  b  -  c  -  d  -  g  -  h(master ,origin / master)--n --o --p(origin / develop)
\\
e - f - i --- m(origin / MyBranch) - ------------
\
j - k - l(MyBranch)


解决方案

评论, git pull --rebase 是:




  • git fetch :远程追踪分支<$ c

    $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ a $ b $ c $ a $ b $ c $ d - g - h(master,origi n / master)
    \\\
    e - f - i --- m(origin / MyBranch)
    \
    j - k - l( MyBranch)


  • git rebase :您在原始/ MyBranch上重新绑定MyBranch

      a  -  b  -  c  -  d --g  -  h(master,origin / master)
    \\
    e - f - i --- m(origin / MyBranch)
    \
    $'''''''(MyBranch)



  • I still don't get what exactly happens with git pull --rebase. I understand the rebasing concept and I have used it in my own local unpublished branch, never when my branch is already published in the remote. I've heard the dangers of doing a rebase with remote, and looking at git pull --rebase, I don't quite grasp how this is safe or when it is unsafe to do so.

    Say for example I am working on MyBranch branch and have been pushing it to the remote so that it gets stored somewhere else other than my own local machine (and probably other people will merge my changes to keep development in sync).

    a--b--c--d--g--h (master, origin/master)
          \
           e--f--i (MyBranch, origin/MyBranch)
    

    Say I do some local development

    a--b--c--d--g--h (master, origin/master)
          \
           e--f--i (origin/MyBranch)--j--k--l (MyBranch)
    

    Say someone else updates MyBranch with the development that has gone into master.

     a--b--c--d--g--h (master, origin/master)
           \         \
            e--f--i---m( origin/MyBranch)
                   \
                    j--k--l(MyBranch)
    

    If I then update by pulling git pull --rebase, how would my tree looks like? Will it only rewrite the history of j, k, l (those local to mine) and put it on top of m, or will it rewrite other history that is already on the remote branch?

    What exactly is the rebase start point and which is the replays?

    Also if origin/MyBranch is being merged into other upstream branch like "develop" then what are the implications of my rebase?

    a--b--c--d--g--h (master, origin/master) --n --o --p (origin/develop)
          \         \                                 /
           e--f--i---m( origin/MyBranch)--------------
                  \
                   j--k--l(MyBranch)
    

    解决方案

    A commented, git pull --rebase is:

    • git fetch: here your remote tracking branch origin/MyBranch has been updated)

      a--b--c--d--g--h (master, origin/master)
             \         \
              e--f--i---m( origin/MyBranch)
                     \
                      j--k--l(MyBranch)
      

    • git rebase: you rebase MyBranch on top of origin/MyBranch

      a--b--c--d--g--h (master, origin/master)
             \         \
              e--f--i---m( origin/MyBranch)
                         \
                          j'--k'--l'(MyBranch)
      

    这篇关于Git pull rebase - 它是什么rebasing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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