简体   繁体   English

在移动GIT存储库时保留GIT提交的历史记录

[英]Preserving history of GIT commits while moving a GIT repository

I have two GIT projects A and B(empty project). 我有两个GIT项目A和B(空项目)。 I want to move the entire project A into project B and preserve the history of commits while moving all the files from A to B. 我想将整个项目A移到项目B中并保留提交历史,同时将所有文件从A移到B。

What's an efficient way to do this using GIT ? 使用GIT进行此操作的有效方法是什么? I tried using git filter-branch but seems like I am not doing it the right way as it gives me "fatal...xyz/is outside repository". 我尝试使用git filter-branch,但是好像我做的方式不正确,因为它给我“致命的……xyz /在存储库之外”。 Could someone give some pointers ? 有人可以指点一下吗?

Thanks ! 谢谢 !

Here is the complete workflow described in our question's comments. 这是问题注释中描述的完整工作流程。

I assume that you want to push the entire history of branch master from Project A to Project B . 我假设您想将分支master的整个历史从Project A推送到Project B。

  1. Project B folder > Initialize the git repo: 项目B文件夹 >初始化git repo:

    git init

  2. Project A folder > Add Project B repo as a new remote: 项目A文件夹 >将项目B存储库添加为新的远程站点:

    git remote add remoteb <urlToB>

  3. Project A folder > Checkout the appropriate branch (if required): 项目A文件夹 >检出相应的分支(如果需要):

    git checkout master

  4. Project A folder > Push the entire history of branch master to remoteb : 项目A文件夹 >将分支master的整个历史记录推送到remoteb

    git push -u remoteb master

If you want additional information about the git push command and parameters, you can find the official documentation here: git push Documentation 如果您需要有关git push命令和参数的其他信息,可以在这里找到官方文档: git push文档

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

相关问题 将 Git 存储库的一部分移动到另一个存储库以保留历史记录 - Moving part of Git repository to another repository preserving history 将 Git 存储库内容移动到另一个存储库以保留历史记录 - Moving Git repository content to another repository preserving history 在保留历史记录的同时永久性地从git存储库中删除文件 - Permanentely remove files from a git repository while preserving the history Git:insert提交保留无ff历史 - Git: insert commits preserving no-ff history 线性化git历史记录,保留所有提交 - Linearize git history, preserving all commits 将目录移动到另一个git存储库,同时保留相关历史记录 - Moving a directory to another git repository while retaining relevant history 合并缺少提交历史记录的git存储库到保留历史记录的存储库 - Merge a git repository lacking commits history to a repository that preserved history 在保留历史记录的同时恢复git目录 - Restoring git directory while preserving history 为 git 历史记录中的所有提交更改 git 子模块的远程存储库 - Changing the remote repository of git submodule for all commits in git history 在保留历史记录的同时将git repo的根目录下移到文件夹层次结构的下一级 - Moving root of git repo down one level in folder hierarchy while preserving history
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM