git - 将文件夹移动到另一个 git 存储库并保留历史记录
问题描述
我想将一个文件夹从 git 移动到另一个 git 存储库。
例如:
这是我在 Git 中当前的文件夹结构。
src/Project/RegistrationBundle
src/Project/PictureGenerationBundle
src/Project/CloudDriveBundle
readme.md
我想将它移动到具有以下文件夹结构的新存储库,但我想保留以前存储库中的 git 历史记录:
src/RegistrationBundle
readme.md
我试图用 git filter-branch 运行它
git filter-branch --subdirectory-filter src/Project/RegistrationBundle/
但是,我找不到自定义文件夹结构的解决方案。
请让我知道它是否可以实现。
非常感谢。
解决方案
您可以更改当前本地存储库上的存储库架构(删除“项目”文件夹),提交更改,然后更改远程 git 存储库。
用于git remote set-url origin <the new git url>
更改存储库 url。
历史将是相同的,因为 .git 文件夹中的本地历史根本没有改变。
推荐阅读
- ruby - Ruby 哈希仅返回 TRUE
- internet-explorer - blueimp Gallery - 错误 Internet Explorer
- json - 解析 Twitch API 响应 PHP
- mysql - 如何使用默认语言查询表中的多语言记录
- javascript - JQuery 脚本未在主页上触发,但相同的 JQuery 在插入的单独 php 页面变量中触发
- wordpress - 如何修复安装在 bitnami magento 容器内的 wordpress 权限?
- c++ - 在“包装器”类中使用原子类型
- javascript - 在页面滚动上添加/删除导航对象类
- .net - 监听 Add_DocumentCompleted 事件 ShowDialog() 后仍然无法操作 DOM
- mysql - 找不到文件“./binlog.000007”(操作系统错误 2 - 没有这样的文件或目录)