![](/img/trans.png)
[英]Git - Track a folder from a separate repository and have a separate repository set up inside of it
[英]Moving the Git Repository to a Child Folder
如果您確實不想創建新的存儲庫,則只需刪除其他文件夾,然后將新的(修剪過的)提交推回現有的存儲庫即可。
請注意,您將在過去的提交中保留其他文件夾的歷史記錄。
“ 將子目錄分離(移動)到單獨的Git存儲庫中 ”中提到的技術實際上將創建一個新的存儲庫 (一個存儲庫的歷史僅涉及要保留的文件夾)
要將git repo移到子文件夾wp-content/themes/lighthouse
同時保留子文件夾的歷史記錄,可以參考以下步驟:
git clone <repo URL>
cd reponame
# checkout all the remote branches locally by git checkout branchname
git filter-branch --subdirectory-filter wp-content/themes/lighthouse -- --all
git push -f --all
現在,git repo移至子文件夾wp-content / themes / lighthouse並保留相關歷史記錄
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.