我想把Git存储库中的一个文件夹分割成一个新的存储库,但我想保留与该文件夹相关的所有打开/关闭的分支和历史记录。
我按照这里描述的步骤进行操作:https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/,但这只适用于单个分支。最终,我得到了一个包含所有(?)提交的新仓库,但没有分支信息。
使用
以下是我目前的情况:
上一个命令似乎没有推送所有分支,我错过了什么吗?
\ Source Repo
--\ AAA
--\ BBB
----\ DDD
----\ EEE
--\ CCC
\ New Repo 1
--\ AAA
--\ CCC
\ New Repo 2 (BBB subfolder)
--\ DDD
--\ EEE
我按照这里描述的步骤进行操作:https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/,但这只适用于单个分支。最终,我得到了一个包含所有(?)提交的新仓库,但没有分支信息。
使用
--all
参数尝试将此操作应用于所有分支,但我不确定如何将所有重写的分支推送到空的远程仓库。以下是我目前的情况:
$ git clone https://github.com/USERNAME/REPOSITORY-NAME
$ cd REPOSITORY-NAME
$ git filter-branch --prune-empty --subdirectory-filter FOLDER-NAME -- --all
此时,如果我查看我的本地存储库,似乎所有历史记录和所有分支都在远程起源中。
$ git remote -v
origin https://github.com/USERNAME/REPOSITORY-NAME.git (fetch)
origin https://github.com/USERNAME/REPOSITORY-NAME.git (push)
$ git remote set-url origin https://github.com/USERNAME/NEW-REPOSITORY-NAME.git
$ git remote -v
origin https://github.com/USERNAME/NEW-REPOSITORY-NAME.git (fetch)
origin https://github.com/USERNAME/NEW-REPOSITORY-NAME.git (push)
$ git push -u origin --all
上一个命令似乎没有推送所有分支,我错过了什么吗?