git学习小结(未完待续)

本文总结了在使用Git过程中遇到的两个常见错误:错误一,由于远程仓库有你本地缺少的更新导致推送被拒绝;错误二,切换分支时本地文件被重写。针对这些问题,提出了相应的解决策略,包括合并远程变化和处理本地修改。
摘要由CSDN通过智能技术生成

错误一

Updates were rejected because the remote contains work that you do

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

错误的原因是:远程仓库包含你本地所没有的更新,可能是被其他人推送进去,故你应该合并这些变化在你准备推送之前


解决办法:

$ git pull origin master     抓取远端的内容
$ git push origin master     重新推送到远程仓库

错误二

Your local changes to the following files would be overwritten by checkout:

Administrator MINGW32 /d/blog (dev)
$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
        .idea/workspace.xml
Please commit your changes or stash them before you switch branches.
Aborting

错误的原因是:直接在远程仓库包操作了,修改了github上面的东西,相当于服务器上面的东西,而本地没有修改,当想改变分支的时候,出现了改变分支的时候会重写文件,所以必须把修改的提交到版本库里面。或者是隐藏在你切换分支之前。


解决办法:

  • 抛弃本地的修改,回到上一个版本

    git reset --hard
    然后,切换你的分支
    git checkout master 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值