如何使没有提交历史的可见github分支? [英] How to make a visible github fork without the commit history?

查看:144
本文介绍了如何使没有提交历史的可见github分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您要将旧的(GitHub)存储库 A 克隆到自己的存储库 B 中.但是,您不需要任何分支,也不需要很长的提交历史记录.您想要的是一个 shallow 克隆,作为仓库最新状态的 snapshot .最好仅使用最新的提交消息,同时仍显示它从A中的哪个点分叉.这在GitHubs Insights > Network选项卡中以图形方式显示,箭头从一个用户回购到另一个用户.

问题是到目前为止我尝试过的解决方案,所有解决方案最终都在GitHub Network图中产生了差距.这可能是因为它们都依赖于删除/恢复.git force 推送,这似乎导致GitHub UI断开克隆/分支,而最终看起来像这样:

我不确定如何最好地表述这个问题,因为已经有几十个听起来很相似(如果不是一样的话),而即使可能,它们似乎都没有解决这个问题.

所以问题是:

如何在仍然删除了大多数提交历史记录的同时,将forks依赖关系保留在GitHubs Network图中?

(我了解我无法删除整个历史记录,并且在图中仍然连接了 something ,但应该不能将叉子压入这样将A中的所有提交转换为一个压缩的提交(如从分叉中看到的),而B中的所有新提交都是正常的?)


我已经看过这些答案,但是它们并没有太大帮助:

解决方案

我认为正确的答案是:

  • 如果您以任何方式修改 Repo-A 的叉子(Repo-B)的前叉历史记录,则Insights > Network graph 将从叉子上脱落.
  • 您的 GitHub 分支仍将显示它是从Repo-A分叉的.
  • 如果您不想使用具有悠久历史的叉子,请执行以下任一操作:

    1. 使用历史记录 创建一个新的分支.
    2. 使用GitHubs UI 进行分叉,然后挤压历史记录(或将内容替换为 shallow 克隆.)

Let's say you want to clone an old (GitHub) repository A into your own repository B. However, you don't need any branches nor do you want the very long commit history. What you want is a shallow clone as a snapshot of the most current status of the repo. Preferably with the latest commit messages, only, while still showing from what point in A it was forked from. This is graphically shown in GitHubs Insights > Network tab, as arrows going from one users repo to another.

The problem is that of the solutions I've tried to so far, all end up making a gap in the GitHub Network graph. This is probably because they all rely on either removing/restoring .git or force pushing which seem to cause the GitHub UI to disconnect the clone/fork, and instead it end up looking like this:

I'm not sure how to best phrase this question as there are already several dozens that sound very similar if not the same, while none of them seem to address this issue, if it is even possible.

So the question is:

How can I keep the forks dependency in GitHubs Network graph, while still having removed most of the commit history?

(I understand that I can't remove the whole history and still have something connected in the graph, but shouldn't it be possible to squash the fork in such a way that all commits in A is turned into one squashed commit (as seen from the fork), while all new ones in B are normal?)


I've looked at these answers, but they were not of much help:

解决方案

I think the right answer is that:

  • If you modify the pre-fork history of your own fork (Repo-B) of Repo-A in any way, the Insights > Network graph will become broken off from the fork.
  • Your GitHub fork will still show that it was forked from Repo-A.
  • If you don't want to work with a fork with that long history, either:

    1. Create a new branch with the history squashed.
    2. Make fork using GitHubs UI and then squash the history (or replace the contents with a shallow clone.)

这篇关于如何使没有提交历史的可见github分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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