git - 推入空的 git repo 时“无法推送引用”
问题描述
我正在尝试从 git 项目中获取一个分支并将其放入另一个 git 存储库但是当我这样做并尝试推送时出现此错误
源引用说明符 refs/heads/master 不对应任何引用错误:不可能将引用推送到“原点”
另外我注意到空项目没有分支,即使是主项目。
解决方案
如果您已经克隆了第一个项目,并且想要将分支推送到第二个远程空存储库(无提交),您可以这样做:
cd /path/to/cloned/first/project
git remote add second https://url/second/empty/repository
git switch <theCorrectBranch>
git push -u second <theCorrectBranch>:main
这将推<theCorrectBranch>
送到第二个远程空存储库的主分支。
推荐阅读
- c - 如何获取用于连接到我的服务器的 IP 地址?
- python - 使用 Keras 错误预测 && 模型创建不存在的类的文本分类(词袋)
- excel - 为什么将联合范围的值存储在数组中只存储第一个范围的值?
- typescript - 打字稿参考问题
- python - Python`str`子类不调用`__add__`
- angular - 永远不会在带有单元测试 angular + jasmine 和 SpyOn 的 switchMap 中调用函数
- excel - 日历中的员工缺勤(vlookup?)
- ios - 运行单元测试时每隔一次Xcode 10“无法安装此应用程序”
- sql-server - 在分子和/或分母中添加转换为小数?
- django - 从 Django 表单中清除“ChoiceField”