首页 > 解决方案 > 将本地存储库添加到 github 存储库中的文件夹

问题描述

背景 我目前正在制作很多反应应用程序。为了将它们全部放在一个存储库中,以免它们与 Python 和其他项目混合,我想将所有项目放入一个 Github 存储库中。

在此处输入图像描述

在那个存储库中,我有诸如“stock-tracker”之类的文件夹,我想使用 Git Bash 将我的存储库推送到该文件。

如果我使用git remote set-url origin https://github.com/leonkuessner/React/stock-tracker.git, 然后git push origin main,我得到错误:

remote: Not Found fatal: repository 'https://github.com/leonkuessner/React/stock-tracker.git/' not found

在此处输入图像描述

问题 如何将本地存储库添加到 Github 存储库中的文件夹

我对 Github 和 Git 都还很陌生,所以如果我解释得不够充分,请在评论中告诉我,我会尽力澄清!

标签: reactjsgitgithub

解决方案


  1. 你需要克隆回购
  2. 在这个 repo 中添加远程到你想要插入 repo 的本地文件夹
  3. 使用 --allow-unrelated-histories 标志从此远程拉到您的原始分支

git remote add another-source ../../some/source

git pull another-source master --allow-unrelated-histories


推荐阅读