注册 登陆

    2021-04-08 23:22:37git 推送更新出现错误: Updates were rejected because the remote contains work that you do

    您现在的位置是: 首页 >  php >  git 推送更新出现错误: Updates were rejected because the remote contains work that you do

    当建立新的仓库,推送本地代码带远程服务器,出现这样的错误,直奔主题吧:

    git的提交步骤:

    1. git init //初始化仓库

    1. git add .(文件name) //添加文件到本地仓库

    2. git commit -m “first commit” //添加文件描述信息    

    3. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支

    4. git push -u origin master //把本地仓库的文件推送到远程仓库


    5. 要想解决以上错误,只需要在4,5之间使用git pull origin master即可

    6. 正确步骤:
      1. git init //初始化仓库

      1. git add .(文件name) //添加文件到本地仓库

      2. git commit -m “first commit” //添加文件描述信息

      3. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支

      4. git pull origin master // 把本地仓库的变化连接到远程仓库主分支

      5. git push -u origin master //把本地仓库的文件推送到远程仓库

    7. 当推送的时候,报 (non-fast-forward),使用强制推送即可:git push --force origin master

    OK
    搞定!!

关键字词: git 推送更新出现错误: Updates were rejected because the remote contains work that you do

0




时间:2021-04-25 23:03:30 null :
可以可以