IDEA git报错Push to origin/master was rejected
时间: 2023-11-25 21:54:01 浏览: 129
IDEA git报错"Push to origin/master was rejected"是因为在将项目上传到已存在文件的GitHub仓库时出现的错误。为了解决这个问题,你可以按照以下步骤进行操作:
1. 首先,在项目根文件夹中右击,选择"Git Bash Here"打开Git命令行工具。
2. 在Git命令行中,输入以下指令来解决报错:
git pull origin master --allow-unrelated-histories
这个指令会将远程仓库(GitHub)的最新代码合并到本地代码中,解决代码冲突。
3. 接下来,输入以下指令来将本地代码强制推送到远程仓库:
git push -u origin master -f
这个指令会强制推送本地代码到GitHub仓库,并更新远程仓库的代码。
通过以上步骤,你应该能够成功解决IDEA git报错"Push to origin/master was rejected"的问题。这样你就能够将项目上传到已存在文件的GitHub仓库了。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [IDEA用Git提交代码失败:Push rejected /Push to origin/master was rejected](https://blog.csdn.net/dontYouWorry/article/details/129159889)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [idea上传代码到github时遇到的Push rejected: Push to origin/master was rejected](https://download.csdn.net/download/weixin_38576229/14045661)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文