排除工作流程以将上游更改合并到分叉的回购中 [英] Troubleshooting the workflow to incorporate upstream changes into forked repo

查看:163
本文介绍了排除工作流程以将上游更改合并到分叉的回购中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我分叉了一个git repo,然后创建了一个名为strlen的分支。



提交PR并进行建议更改:。



以下是我试图合并上游变更:

第一部分:从上游获取和合并:

  git fetch upstream 
git merge upstream / master

B部分:挤压上游提交,仅保留一个提交评论,以便对我的特定更改进行评论:

  git rebase --interactive HEAD〜2 




注意:对于互动部分,除了最新的一个(我的)在顶部之外,我对所有提交
做了(撤销)。




  git push origin strlen 

code>

squash似乎没有像这次宣传的那样:所有的干预提交**以及t他介入的文件更改**在strlen分支上可见。新的Pull Request显示所有内容,而其目的是仅显示我的文件更改。

所以,任何有关

的提示$ (b)我应该以不同的方式执行rebase
  • 或(b)完全采用另一种方法
  • >


    更新从VonC的很好的回答中,我添加了一些更多的细节,这里是当前的解决方案: b
    $ b

      git remote add upstream https://github.com/foo/bar.git 
    git checkout master
    git fetch上游
    git checkout strlen
    #进行更改。如果使用IJ,则可以创建CL并在本地提交CL。
    #或者简单地使用命令行并提交-m创建一些更新
    git rebase -i upstream / master#将新的提交压缩到
    #用于创建PR的原始提交
    git push -f来源

    上述工作流程非常有效。事实上,它足以解决由我原来的工作流程引起的问题(合并错误)。

    解决方案

    c $ c> upstream / master 更新一个PR分支。



    在更新的<$ c $之上重新绑定本地PR分支c> upstream / master :

      git fetch upstream 
    git checkout strlen
    git rebase -i upstream / master#如果你想要的话可​​以压扁
    git push -f origin

    您强制推送,但您的PR会自动更新,同时考虑到 strlen 分支的新历史记录。



    详情请参阅:


    I forked a git repo, and then created a branch called "strlen."

    After submitting a PR and making suggested changes: .

    The following was my attempt to merge in upstream changes:

    Part A: fetch and merge from upstream:

    git fetch upstream
    git merge upstream/master
    

    Part B: squash the upstream commits, retaining only a single commit comment for my particular changes:

    git rebase --interactive HEAD~2
    

    Note: for the interactive part, I did a s(quash) on all of the commits except for the latest one (mine) at the top.

    Part C: push the changes back to my fork on github:

     git push origin strlen
    

    The "squash" did not seem to do as advertised this time: all of the intervening commits **as well as the intervening file changes ** are visible on the strlen branch. The new Pull Request shows everything, whereas the intention was to display only my file changes.

    So , any hints on

    • (a) should I have performed the rebase somewhat differently
    • or (b) take another approach altogether

    UPDATE From VonC's great answer, I added some more details and here is the current solution:

    git remote add upstream https://github.com/foo/bar.git
    git checkout master
    git fetch upstream
    git checkout strlen
    # Make changes. If using IJ you can then create CL and commit the CL locally.
    #   Alternatively simply use command line and do commit -m "Made some updates"
    git rebase -i upstream/master  # Squash the newer commits into 
                                   # the original one used to create the PR
    git push -f origin
    

    The above workflow worked really well. Well enough in fact to fix the problems (merge errors) caused by my original workflow.

    解决方案

    You don't merge upstream/master when updating a PR branch.

    You rebase your local PR branch on top of the updated upstream/master:

    git fetch upstream
    git checkout strlen
    git rebase -i upstream/master # you can squash if you want there
    git push -f origin
    

    You force the push, but your PR will be updated automatically, taking into account the new history of the strlen branch.

    See more at:

    这篇关于排除工作流程以将上游更改合并到分叉的回购中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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