首页 > 解决方案 > 解决only-a-file push的拒绝推送

问题描述

如何解决 only-a-file push 的被拒绝推送以替换其在 github 上的远程对应项?
试试这个https://happygitwithr.com/push-rejected.html 没有任何成功

例如消息

 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/abdulbadii/MatrixMultiplier'
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

标签: gitgit-commitgit-push

解决方案


似乎其他人在同一个 git 分支上工作,所以只需使用 git stash

然后运行 git pull origin branch_name ,然后获取您的更改,运行 git stash pop

之后推送你的代码


推荐阅读