首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >推送到同一个github存储库spring并响应项目

推送到同一个github存储库spring并响应项目
EN

Stack Overflow用户
提问于 2022-06-16 09:55:01
回答 1查看 47关注 0票数 0

我想将react和spring项目上传到同一个存储库中。当我试图推另一个后推一个时,我会犯这个错误。当我使用-强制时,另一个项目的代码被删除。如何将两者存储在存储库中?

代码语言:javascript
复制
bar1s@DESKTOP-C8L726O MINGW64 ~/Desktop/spring/auction-project (master)
$ git push -u origin master
To https://github.com/cevikbaris/Auction-Website.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/cevikbaris/Auction-Website.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
EN

回答 1

Stack Overflow用户

发布于 2022-06-17 21:17:56

您只能将这两个项目存储在同一个存储库中,或者存储在存储库上的两个不同的分支上,或者将两个项目存储在同一个目录中。

这里的问题是:当您推送一个项目时,会对在线存储库进行更改,然后您的本地存储库中就没有了这些更改。因此,您不能推送,因为在这种情况下,git不知道如何处理不同的代码。

如何修复这个

解决方案1:

将两个项目存储在相同的目录中。要快速解决问题,只需运行

代码语言:javascript
复制
git pull

在尝试推动你的项目之前。

这将将更改拉到您的本地存储库,如果您有任何同名目录,则可能会造成混乱。

但你可以推。

解决方案2:

为两个项目创建不同的分支。

使用以下命令执行此操作:

代码语言:javascript
复制
git branch <branch name> //create a new branch
git branch               //view your branches
git switch <branch name> //switch to the specified branch

然后,您可以将项目推送到单独的分支上,同时仍然在同一个存储库中工作。

参考资料:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72643941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档