解决git push远程仓库 时 Updates were rejected because the remote contains work that you do问题

版权声明:谢谢你那么厉害还看了我的文章,欢迎转载交流学习~ https://blog.csdn.net/kilotwo/article/details/85564154

今天提交的时总会出现这样的错误,经过网上查询,发现解决方案如下

一般git 提交的步骤:

  1. git init //初始化仓库

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

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

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

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

正确步骤:

  1. git init //初始化仓库

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

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

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

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

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

如果两人同时修改了同一部分的源代码,push 时就很容易发生冲突。所以多名开发者在同一个分支中进行作业时,为减少冲突情况的发生,建议更频繁地进行 push 和 pull 操作。

猜你喜欢

转载自blog.csdn.net/kilotwo/article/details/85564154
今日推荐