将 2 个本地位置添加到相同的 Git 存储库

Add 2 local locations to same Git repo

我已经在 Git 上谷歌搜索了几个小时了,但我无处可去,所以希望你能帮忙。

我有本地路径 /path/to/somewhere/ 这与我的远程 BitBucket 存储库同步 https://bitbucket.org/company/somewhere.git

现在我想添加另一个文件夹,比如 /path/to/there/ 我希望它出现在同一个存储库中 https://bitbucket.org/company/somewhere.git/there/

我尝试使用 "git subtree add --prefix=there https://bitbucket.org/company/somewhere.git" 但它的响应是:

前缀 'somewhere' 已经存在。

当我登录到 Bitbucket 并检查时,它没有。

Git 不是这样工作的,您必须为 /path/to/there/ 再创建一个存储库才能将其作为子目录包含到您的 /path/to/somewhere/ 中。 当您有两个存储库时,您可以:

$ cd /path/to/somewhere/
$ git subtree add --prefix=there https://bitbucket.org/company/THERE.git master

然后 /path/to/somewhere/ 中出现一个新目录 there

有关详细信息,请查看 this