【发布时间】:2016-04-13 18:01:04
【问题描述】:
我在 github 中有一个包含许多文件夹(f1、f2、f3)的 repo-a。 我想用 f1 创建一个带有所有分支的新仓库(repo-b)。
Repo-a
|_ f1
|_ f2 ------+
|_ f3 |
| Copy folder with branches and history
Repo-b |
|_ f2 <-----+
这就是我正在做的,但它只推动一个分支:
-
克隆原始仓库
-
现在删除除我需要的文件夹之外的所有内容
git filter-branch --prune-empty --subdirectory-filter f2 -- --all
-
然后我将远程原点更改为新的代表
git remote set-url origin https://github/myuser/repo-b
-
最后我推动一切
git push --all origin
正如我所说,当我检查 repo-b 时,它只包含一个分支,而不是所有分支。
有什么想法吗??
谢谢。
【问题讨论】:
-
感谢您的链接,但它在第 5 点失败。(git filter-branch --prune-empty --subdirectory-filter \ YOUR_FOLDER_NAME master)。任何想法?它说“修改错误”