[英]How to move one repo to another repo folder and keep git history?
[英]Move folder to another git repository and keep the history
我想將文件夾從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/
但是,我找不到自定義文件夾結構的解決方案。
請讓我知道是否可以實現。
非常感謝。
您可以更改當前本地存儲庫上的存儲庫體系結構(刪除“ Project”文件夾),提交更改,然后更改遠程git存儲庫。
使用git remote set-url origin <the new git url>
更改存儲庫url。
由於.git文件夾中的本地歷史記錄完全沒有更改,因此歷史記錄將是相同的。
git filter-branch --subdirectory-filter src/Project/RegistrationBundle/ -- --all
當您運行此命令時,您所擁有的只是RegistrationBundle中的文件,然后在新存儲庫中添加一個帶有RegistrationBundle路徑的遙控器,然后執行git pull
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.