How to make a visible github fork without the comm

2019-09-02 05:48发布

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:

enter image description here

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:

2条回答
霸刀☆藐视天下
2楼-- · 2019-09-02 05:56

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.)
查看更多
SAY GOODBYE
3楼-- · 2019-09-02 06:06

Those lines are generated directly from the git history. If there's no history of a fork (or commits), there'll be no lines.

In short, if you want the line, you need to fork.

查看更多
登录 后发表回答