TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Moving Git commits between repos (2017)

41 点作者 piinbinary超过 1 年前

6 条评论

jez超过 1 年前
If the goal is to move <i>all</i> the commits of one repo into another repo, Git provides subtree merges:<p><a href="https:&#x2F;&#x2F;docs.github.com&#x2F;en&#x2F;get-started&#x2F;using-git&#x2F;about-git-subtree-merges" rel="nofollow">https:&#x2F;&#x2F;docs.github.com&#x2F;en&#x2F;get-started&#x2F;using-git&#x2F;about-git-s...</a><p>For companies that started out making lots of small repositories that want to moev incrementally to a monorepo, this strategy can be useful because it sets up the smaller repo as a self-contained unit of the larger repo, preserving things like git commit history and git blames. After a subtree merge, further steps can more tightly integrate the code into the larger repository (i.e., so that it is no longer wholly contained in the subtree).
oftenwrong超过 1 年前
I recommend using <a href="https:&#x2F;&#x2F;github.com&#x2F;newren&#x2F;git-filter-repo">https:&#x2F;&#x2F;github.com&#x2F;newren&#x2F;git-filter-repo</a> instead of filter-branch.
jackconsidine超过 1 年前
I merged two codebases (several thousand commits each) into a monorepo using a similar strategy. Instead of top level files in an api repo, and top level files in a web repo, we have packages&#x2F;api and packages&#x2F;web. It feels magical that I can open up a blame for a file in either package when most commits occurred in separate repos spanning back 5 years
jaeckel超过 1 年前
The mainstream version of this post is called subtree-merge and supported by recent Git versions ootb
whoomp12341超过 1 年前
How is this different from running git pull or git push to a remote?
评论 #38846399 未加载
评论 #38856256 未加载
whateveracct超过 1 年前
huh good to know. I often just make and apply patches when I&#x27;m dealing with different histories. Doesn&#x27;t always work though.