更新分叉库和automerge [英] Update forked repository and automerge

查看:120
本文介绍了更新分叉库和automerge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在github上创建了一个公共存储库,创建了一个修复问题并提交了被接受的请求的分支。
现在我想将我的fork更新为最新版本的公共存储库,从那时起,已有100多个提交。由于我的更改已被接受,我只想获取最新的存储库,而无需从我自己的分支中合并任何内容。
然后我想在最新版本上创建一个新的功能分支来提交进一步的修复。



我已阅读过几篇文章,例如




  • 什么是源和目标?我期望看到来源



    https://github.com/Microsoft/perfview.git/master



    和Target

    https://github.com/Alois-xx/perfview.git/master



    这将有助于不盲目地合并错误的东西。合并工具期望我为每个文件做出决定,这让我感到非常困扰。至少在Visual Studio中似乎没有选择简单地从Source获取所有内容并完成它。

    什么是神奇的命令行,不需要手动合并数百个文件就可以批量更新我的分支?

      git merge -Xtheirs ...? 

    我试图为我的fork创建一个pull请求,但是github也抱怨需要手动合并。最简单的事情就是删除我的fork并重新创建它,但由于我们有版本控制,应该有一个简单的方法。

    解决方案

    最简单的方法是将两个存储库克隆到不同的目录中。


    • Fork / Repo

    • 原始/回购



    然后我删除了Fork / Repo中除.git目录之外的所有内容,然后我将Orig / Repo的内容复制到我的fork中(除了.git目录),然后我承诺。

    这很容易,如果在合并时没有进行重新绑定,则可以在不保存实际内容的情况下获取提交消息的历史记录。当你更新fork时,你有一个提交包含了所有的改变,如果你想查看自上次fork以来的更改,那么这很好。


    I have forked on github a public repository, created a branch that fixes an issue and submitted a pull request which was accepted. Now I want to update my fork to the latest version of the public repository which has got 100+ commits since then. Since my change was accepted I simply want to fetch the latest repository without merging anything from my own fork. Then I want to create a new feature branch on the latest version to submit further fixes.

    I have read several posts e.g.

    which deal with that issue but that is far away from simple because git wants me to merge every single commit which it cannot automerge. I have changed on my fork one or two files but git wants me to merge hundreds of files on my fork. That cant be right.

    I did for my PerfView clone basically

    1. git clone https://github.com/Alois-xx/perfview.git
    2. git remote add upstream https://github.com/Microsoft/perfview.git
    3. git fetch upstream
    4. git checkout master
    5. git rebase upstream/master

    I then get a warning that I need to merge things one by one for hundreds of files.

    C:\Source\git\PerfView_Fork\perfview>git rebase upstream/master
    First, rewinding head to replay your work on top of it...
    Applying: Updated HtmlJS directory to contain a stock ASP.NET 5 Service.  We can use this to build the back end of the cross platform version of PerfView.
    .git/rebase-apply/patch:9414: trailing whitespace.
    The basic architecture for the app is there are two processes
    .git/rebase-apply/patch:9416: trailing whitespace.
       1. One that acts as a 'back end' that acts as a data model.
    .git/rebase-apply/patch:9417: trailing whitespace.
        This has no user interface and communiates to the UI by
    .git/rebase-apply/patch:9419: trailing whitespace.
            (that is a REST API)  This is responsible for all data.
    .git/rebase-apply/patch:9424: trailing whitespace.
       2. A second process that
    warning: squelched 4 whitespace errors
    warning: 9 lines add whitespace errors.
    error: Failed to merge in the changes.
    Using index info to reconstruct a base tree...
    M       src/HtmlJs/documentation/DesignBasics.md
    M       src/HtmlJs/documentation/DevNotes.md
    M       src/PerfView/Properties/AssemblyInfo.cs
    A       src/PerfView/SupportDlls/UsersGuide.htm
    Falling back to patching base and 3-way merge...
    Auto-merging src/PerfView/Properties/AssemblyInfo.cs
    CONFLICT (content): Merge conflict in src/PerfView/Properties/AssemblyInfo.cs
    Auto-merging src/HtmlJs/PerfDataService/Views/static/help.html
    Patch failed at 0001 Updated HtmlJS directory to contain a stock ASP.NET 5 Service.  We can use this to build the back end of the cross platform version of PerfView.
    The copy of the patch that failed is found in: .git/rebase-apply/patch
    
    When you have resolved this problem, run "git rebase --continue".
    If you prefer to skip this patch, run "git rebase --skip" instead.
    To check out the original branch and stop rebasing, run "git rebase --abort".
    

    I have tried Visual Studio which also follows the git workflow where I have to deal with every single merge error. That should be a common issue to skip merging and simply take the branch as is from the master but I was unable to find a satisfying solution so far.

    Why should I even need to merge files which I did never touch on a branch (main) to which I never did any commit at all? That makes no sense to me. The Visual Studio merge dialog shows me

    What is Source and Target? I would expect to see as source

    https://github.com/Microsoft/perfview.git/master

    and Target

    https://github.com/Alois-xx/perfview.git/master

    That would be helpful to not blindly merge the wrong thing. What is really disturbing me that the merge tool expects me to take a decision for every single file. There seems at least in Visual Studio no option to simple take everything from Source and be done with it.

    What is the magic command line looking to do a bulk update of my fork without needing to merge manually hundreds of files?

    git merge -Xtheirs ... ? 
    

    I have tried to create a pull request for my fork but github also complains about manual merges which are necessary. The easiest thing would be to delete my fork and recreate it but since we have version control there should be an easy way.

    解决方案

    The easiest way was actually to clone both repositories into different directories.

    • Fork/Repo
    • Orig/Repo

    Then I did delete everything in Fork/Repo except the .git directory and then I did copy the contents of Orig/Repo into my fork (except the .git directory) which I then committed.

    That is easy and if one does a rebase while merging nothing you get the history of commit messages without saving the actual contents. When you update the fork you have one commit which contains all changes together which is nice if you want to see changes since the last fork.

    这篇关于更新分叉库和automerge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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