简体   繁体   English

如何在保留提交历史记录的同时将两个单独的 git 存储库作为两个目录添加到一个存储库中?

[英]How to add two separate git repos into one repo as two directories while preserving commit history?

I was developing a full-stack web application and for that, I created two separate repositories for the front-end and back-end as I develop.我正在开发一个全栈 web 应用程序,为此,我在开发时为前端和后端创建了两个独立的存储库。 The two repositories are,这两个存储库是,

  1. projectName_api项目名称_api
  2. projectName_client projectName_client

Now I need to create one repository 'projectName' which contains these two separate git repositories as directories without deleting the commit history.现在我需要创建一个存储库“projectName”,其中包含这两个单独的 git 存储库作为目录,而不删除提交历史记录。

api --> projectName_api git repo api --> projectName_api git repo

client --> projectName_client repo客户端 --> projectName_client 存储库

|projectName
|--api
|--client
|--package.json

It will be better if the history of git repos can be put into branches like frontend and backend with separate history in those branches如果可以将 git 存储库的历史记录放在前端和后端等分支中,并且在这些分支中具有单独的历史记录,那就更好了

The usual approach would be rather to use git submodules , referencing those two repositories in your main project repository.通常的方法是使用git submodules ,在您的主项目存储库中引用这两个存储库。

That way:那样:

  • they keep their history他们保留他们的历史
  • they keep their own branches他们拥有自己的分支机构

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何合并两个git repos,同时保留两个历史和一个哈希值? - How to combine two git repos, preserving the history of both, and the hashes of one? 如何在保存提交历史记录的同时还原git repo? - How to revert git repo while preserving the commit history? 如何将两个 git 存储库作为一个存储库进行管理,但又保持独立? - How to manage two git repos as a single repo, yet stay separate? 创建新的主仓库。 将两个单独的仓库添加到主仓库中,但不合并它们,并且不会丢失历史记录 - Create new Main repo. Add two separate repos into Main repo but not merge them and without losing history 如何将父文件夹中的两个 git 回购合并为一个回购? - How to combine two git repos into one repo in parent folder? 如何在不更改历史记录提交哈希的情况下将一个git repo分为两部分 - how to split one git repo into two without changing the history commit hash 当两个人正在处理它们并同时更改提交历史记录时,如何同步 git repos? - How to sync git repos when two people are working on them and changing the commit history simultaneously? 两个不同的本地存储库提交到一个 Github 存储库 - Two different local repos commit to one Github repo 如何将 svn repos 合并到一个具有干净历史记录的 git repo 中? - how to merge svn repos into one git repo with clean history? Subversion,两个仓库,如何提交到一个特定的仓库? - Subversion, two repos, how to commit to a specific one?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM