0


git第一次推送出现推送被拒绝

前言

git 第一次推送出现以下错误

! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://gitee.com/fengshangyunwang/iot-front-end.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.


一、解决方案

这个错误提示说明你未能成功推送代码到远程仓库,因为远程仓库中存在你没有本地副本的分支,或者你未能解决与远程仓库中已有分支的冲突。为了解决这个问题,你可以使用以下命令

1.git pull:该命令将会获取远程仓库最新的代码,并且尝试自动合并到当前分支。如果存在冲突,需要手动解决之后再次提交。

git pull origin master

2.git fetch:该命令将会获取远程仓库最新的代码更新,但不会自动合并到当前分支,需要手动进行合并。

git fetch origin master
git merge origin/master

3.强制推送:如果你确信本地分支是正确的,可以使用强制推送来覆盖远程仓库中的分支,使用后,请确保你知道这样做的后果。

git push -f origin master
标签: git

本文转载自: https://blog.csdn.net/wsq88888888/article/details/133878650
版权归原作者 写Bug的王二 所有, 如有侵权,请联系我们删除。

“git第一次推送出现推送被拒绝”的评论:

还没有评论