美文网首页
git 相关问题记录

git 相关问题记录

作者: 辉涛 | 来源:发表于2022-04-13 14:33 被阅读0次
    $ git push origin master
    git@gitee.com: Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
    

    需要设置公钥:

     ssh-keygen -t rsa -C 'zhuhuitao_struggle@163.com'
    
    
    生成公钥
    $ git push -u origin master
    To gitee.com:SixtecCloud/sixtec-cloud-android-repo.git
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'gitee.com:SixtecCloud/sixtec-cloud-android-repo.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
    remote: Enumerating objects: 2778, done.
    remote: Counting objects: 100% (2778/2778), done.
    remote: Compressing objects: 100% (1836/1836), done.
    remote: Total 2778 (delta 847), reused 2772 (delta 847), pack-reused 0
    Receiving objects: 100% (2778/2778), 55.85 MiB | 10.21 MiB/s, done.
    From gitee.com:SixtecCloud/sixtec-cloud-android-repo
     * branch            master     -> FETCH_HEAD
     * [new branch]      master     -> origin/master
    fatal: refusing to merge unrelated histories
    
    

    当执行完pull后,再次提交:

    $ git push -u origin master
    To gitee.com:SixtecCloud/sixtec-cloud-android-repo.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'gitee.com:SixtecCloud/sixtec-cloud-android-repo.git'
    hint: Updates were rejected because the tip of your current branch is behind
    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.
    
    

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

    出现这个错误的原因是git本地仓库的当前版本低于远程仓库的版本(大白话就是:你在github上进行的修改没有同步到本地git仓库中)。

    在终端下输入:git push -u origin master -f
    这句话执行的后果就是在远程仓库中进行的相关修改会被删除,使远程仓库回到你本地仓库未修改之前的那个版本,
    然后上传你基于本地仓库的修改。这如果在企业开发中就会让别的程序员的这些天的开发付之东流,一切回到解放前。

    相关解决办法:
    https://blog.csdn.net/IT_SoftEngineer/article/details/107133313

    相关文章

      网友评论

          本文标题:git 相关问题记录

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