git push

作者: 栗子_978b | 来源:发表于2018-11-19 22:12 被阅读0次

    使用git push,根据远程仓库和本地仓库的属性不同,主要分为以下几种情况。

    1. 要是本地仓库比远程仓库提前,使用git push后,远程仓库的文件版本完全被替换成本地仓库的版本。
    2. 要是本地仓库比远程仓库落后,则使用git push
    error: failed to push some refs to 'git@code.aliyun.com:hhhdddgggg/engine.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下来,接下来本地仓库,暂存区和工作区都会被替换成远程仓库的版本。

    1. 要是远程仓库和本地仓库分叉,即原本远程仓库和本地仓库都是版本A,后来远程仓库对其中某些文件进行了修改,成立版本B,本地仓库对某些文件进行了修改,成了版本C。则使用git push
    error: failed to push some refs to 'git@code.aliyun.com:hhhdddgggg/engine.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把远程仓库的文件拉下来,再合并冲突,再git push.

    1. 要是远程仓库和本地仓库都不是一个版本,则还是得先git pull --allow-unrelated-histories,而且得是强行拉取,解决完冲突后再合并。

    相关文章

      网友评论

          本文标题:git push

          本文链接:https://www.haomeiwen.com/subject/cxrzfqtx.html