将Git存储库移动到子文件夹

问题描述 投票:1回答:2

我在我的Wordpress网站上使用Github。

目前它跟踪父Wordpress文件夹,它实质上跟踪所有内容。

enter image description here

我希望它只有一个只有主题的git,位于wp-content/themes/lighthouse

有没有一种简单的方法让这个存储库只是主题而不是Wordpress中的所有内容?无需创建新的存储库?

wordpress git github version-control repository
2个回答
0
投票

如果你真的不想创建一个新的仓库,你只需删除其他文件夹,然后将新的(修剪过的)提交推回到现有的仓库。 请注意,您将保留过去提交中的其他文件夹历史记录。

Detach (move) subdirectory into separate Git repository”中提到的技术实际上会创建一个新的回购(一个历史记录只涉及您要保留的文件夹)


0
投票

要将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并保留相关历史记录

© www.soinside.com 2019 - 2024. All rights reserved.