git - 如何使用 rebase 从 repo 中提取而不获得较旧的提交
问题描述
我有一个包含近 900 次提交的父仓库,我正在从中创建子仓库。我已经尝试了我所知道的几乎所有可能的变体,包括使用父 repo 作为模板。
我想要实现的与 repo 模板提供的类似。我想从单一提交的新回购开始。当我从父 repo 中提取时出现问题(它在子 repo 的提交历史中带来了父 repo 的所有 900 次提交)。我还尝试了几种用于拉取模板/上游更改的变体。以下是我使用过的一些命令。
我已将模板仓库设置为
upstream
使用git remote add upstream <template-repo-url>
git pull upstream main
git merge upstream/main
如果我使用模板 repo 方法并从子项中提取,我会在第一次提取时出现不相关的历史错误。但是,如果我使用--allow-unrealted-histories
.
最后,我想知道如何从单个提交开始从父仓库创建子仓库并获取所有更改(提交)(我更喜欢使用 rebase,因为这将为子仓库带来单独的提交,以获取有关已修复内容的详细信息)。
Parent repo:
900 commits
--- (at this point I create child repo)
fixed(layout): navbar overlay
feat(demo): add code snippets
child repo:
single commit
--- (Above is all the commits of parent repo in single commit when I created child repo)
(now get all the commits separately)
fixed(layout): navbar overlay
(there might me child repo's own commits...)
feat(demo): add code snippets
我也可以放弃使用模板的想法,如果我能实现上面说明的提交历史。
解决方案
. 我想从单一提交的新回购开始。
我会简单地获得原始存储库的存档(git archive
或GitHub tarball)(意思是最新提交的内容,没有任何历史记录,因此没有 900 个以前的提交)
我会在一个新的存储库中扩展该存档,添加README
原始存储库的 URL,以防需要浏览这些文件的过去历史记录。
推荐阅读
- json - 如何使用 jq 打印特定的对象键?
- date - Flutter TextField 输入验证日期
- html - 无边框后如何删除剩余空间
- azure-devops - 是否可以批准来自微软团队中 azure repos 的拉取请求?
- asp.net-mvc - 在两个日期之间作为 where 条件以及 Linq 中的 GETALL() 方法
- javascript - 如何正确获取输入数据并在函数中调用?
- graphviz - 如何在 Graphviz 中划掉一个节点?
- r - 根据分组和索引汇总一列中的值
- vuejs2 - 根据选择选项值过滤 Vue 列表
- javascript - 非顺序事件冒泡 onClick vs addEventListener