在工作中,你总是与代码打交道,上传代码的时候,相信你不是用svn,就是用Git版本控制器,下面是最近这几天整理下来经常会遇到的Git的一些错误的解决访问,希望能帮助到你。
1 git pull遇到错误:error: Your local changes to the following files would be overwritten by merge:
方法1:如果你想保留刚才本地修改的代码,并把git服务器上的代码pull到本地(本地刚才修改的代码将会被暂时封存起来)
git stash
git pull origin master
git stash pop
如此一来,服务器上的代码更新到了本地,而且你本地修改的代码也没有被覆盖,之后使用add,commit,push 命令即可更新本地代码到服务器了。
方法2、如果你想完全地覆盖本地的代码,只保留服务器端代码,则直接回退到上一个版本,再进行pull:
git reset --hard
git pull origin master
2 在git push origin master时出现以下这个问题时:
error: failed to push some refs to 'git@github.com:yangchao0718/cocos2d.git
hint: Updates were rejected because the tip of your current branch is behin
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
出现错误的主要原因是github中的README.md文件不在本地代码目录中 可以通过如下