git使用之hint: the same ref. If you want to integrate the remote changes, use hint: ‘git pull’ before pushing again.没拉代码提交代码不被允许-如何强制推送本地代码覆盖远程仓库-优雅草央千澈解决方案

1,问题

hint: ‘git pull’ before pushing again

To https://gitee.com/youyacao/doc.youyacao.com.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/youyacao/doc.youyacao.com.git'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决方案

强制推送本地内容覆盖远程仓库方法:

执行
git push -f origin <branch_name>

这里的 -f 或 —force 参数表示强制推送,origin 是远程仓库的别名,<branch_name> 是你要推送的分支名称。

请注意,强制推送可能会导致远程仓库中的提交历史被覆盖,因此在使用时要谨慎

优雅草央千澈这里是默认分支master,于是执行:

git push -f

git使用之hint: the same ref. If you want to integrate the remote changes, use hint: ‘git pull’ before p_远程仓库


直接成功,结束。