git踩坑综合症

使用git真的是让我受尽了折磨,不写个集合都以为对不起本身踩过的那些坑啊git

  1. 错误一:failed to push some refs to git
    $ git push -u origin mastergithub

    To git@github.com:yangchao0718/cocos2d.gitfetch

    ! [rejected]        master -> master (non-fast-forward)

    error: failed to push some refs to 'git@github.com:yangchao0718/cocos2d.gitcode

    hint: Updates were rejected because the tip of your current branch is behinip

    hint: its remote counterpart. Integrate the remote changes (e.g.rem

    hint: 'git pull ...') before pushing again.it

    出现错误的主要缘由是github中的README.md文件不在本地代码目录中ast

    能够经过以下命令进行代码合并【注:pull=fetch+merge]date

    git pull --rebase origin master下载

    执行上面代码后能够看到本地代码库中多了README.md文件

    此时再执行语句 git push -u origin master便可完成代码上传到github

2.错误二:You have not concluded your merge. (MERGE_HEAD exists)
Git本地有修改如何强制更新
本地有修改和提交,如何强制用远程的库更新更新。我尝试过用git pull -f,老是提示 You have not concluded your merge. (MERGE_HEAD exists)。
我须要放弃本地的修改,用远程的库的内容就能够,应该如何作?傻傻地办法就是用心的目录从新clone一个,正确的作法应该是:

git fetch --allgit reset --hard origin/mastergit fetch 只是下载远程的库的内容,不作任何的合并git reset 把HEAD指向刚刚下载的最新的版本

相关文章
相关标签/搜索