如何在没有合并提交或不使用CLI的情况下使GitHub保持最新状态? [英] How to keep a GitHub fork up to date without a merge commit or using CLI?

查看:112
本文介绍了如何在没有合并提交或不使用CLI的情况下使GitHub保持最新状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

贡献回购的普通GitHub流程是创建上游分支,在您进行更改的地方克隆本地副本,然后将其推回分支,然后创建PR以将您的更改合并到上游.

The normal GitHub flow to contribute to a repo is to create a fork of the upstream, clone a local copy where you make changes, then push back up to your fork and then create a PR to have your changes merged into upstream.

但是如果之后上游发生了变化,那么如何在不创建合并提交的情况下(又不用git CLI的情况下)更新分叉?

But if upstream changes after that, how do you update your fork without creating a merge commit (and also without using the git CLI)?

我已经知道如何以创建合并提交或依赖git命令行界面的方式执行此操作.该问题专门用于仅使用GitHub.com网站或GitHub桌面应用程序(无CLI).

I already know how to do this in a way that will create a merge commit or which depend on the git command line interface. This question is specifically about using the GitHub.com website or GitHub Desktop application only (no CLI).

由于这是一个非常常见的工作流程,因此似乎应该有一些使用GitHub GUI进行操作的简单方法.

Since this is a very common workflow it seems like there should be some simple way to do it using the GitHub GUI.

要重申:使用CLI或创建合并提交的所有答案(例如

To reiterate: any answers that use the CLI or create a merge commit (e.g. this way) will not be answering this question since I'm explicitly looking for a non-CLI solution.

推荐答案

使用GitHub Desktop 从1.0.7版起,考虑以下内容:

This is feasible with GitHub Desktop since version 1.0.7 considering the following:

  • 如果当前分支在上游没有任何提交(派生的原始回购),则可以在不创建新合并提交的情况下提取新提交

  • If the current branch does not have any commits ahead upstream (the original repo of the fork), the new commits can be pulled without creating a new merge commit

在GitHub Desktop中:

In GitHub Desktop:

  1. File > Clone Repository

Fetch origin,它也会自动获取上游

Fetch origin, which will automatically fetch the upstream as well

通过单击显示Current Branch

单击底部的Choose a branch to merge into <branch>

搜索upstream/<branch>,然后单击Merge upstream/<branch> into <branch>

推到原点,等等!

  • 否则,如果当前分支已经在派生分支之前提交了,那么当然必须创建一个合并提交或重新设置并强制推送.对于可能更可取的重新定基,请执行以下操作:

  • Otherwise, ff the current branch has commits ahead of the fork, then of course one has to create a merge commit or rebase and force push. For rebasing which might be more preferable, do the following:

    1. 在GItHub Desktop中,从菜单转到Branch,然后从Rebase Current Branch

    搜索upstream/<branch>,然后单击Start Rebase

    解决由于重新设置而发生的所有冲突

    Solve any conflicts that have occurred from the rebase

    强制压入原点.出于明显的原因,您会因此收到警告.

    Force push to origin. You will get a warning for this for obvious reasons.

  • 为避免在当前分支位于上游分支的前面和后面时强行推动工作,请创建新的合并提交或:

    For avoiding force-pushing to your work when your current branch is both ahead and behind its upstream counterpart, either create a new merge commit or:

    • 根据您的所有更改创建新分支

    • Make a new branch based with all your changes

    如果需要,将原始分支重置为原始状态(在与原始存储库分离之前)

    If needed, reset the original branch to its original state (before it diverged from the original repo)

    执行第一个方案中的步骤并将您的更改合并到分支中.

    Perform the steps from the first scenario and merge your changes into your branch.

    是的,目前看来不可能通过GitHub网站从原始存储库中进行拉取而无需创建拉取请求和合并提交 .

    And yes, it seems that pulling via the GitHub website from the original repo without creating a pull request and merge commit is not possible at this moment.

    第一种情况的演示GIF: https://imgur.com/a/8wci2yf

    Demo GIF for first scenario: https://imgur.com/a/8wci2yf

    与此相关的一些GitHub问题:

    Some GitHub issues related to this:

    桌面中的多远程支持

    这篇关于如何在没有合并提交或不使用CLI的情况下使GitHub保持最新状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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