Git系列:常见报错处理

Git系列博客:

  1. Git系列:GitHub建仓及远端同步步骤总结,link
  2. Git系列:入门必备指令详解,link
  3. Git系列:常用操作一指禅,link
  4. Git系列:常见指令辨析,link
  5. Git系列:常见报错处理,link

本文小结Git使用过程中遇到的常见报错处理。

报错:fatal: could not read from remote repository, please make sure you have the correct access rights

  • 根因:没有在Github上配置git本地秘钥

  • 解决方案

  • 确保本地git账号设置ok

    • 配置指令如下
      • git config –global user.name "xxxxx"
        • git config –global user.email "[email protected]"
        • 查看是否配置成功,用命令:git config --global --list
    • 查看本地秘钥是否与Github账户的公钥配置一致
      • 生成秘钥
        • ssh-keygen -t rsa -C “上面的邮箱”
        • 注:执行上面命令后,连续回车3次
      • 打印
        - cd ~/.ssh,进入ssh目录
        - cat id_rsa.pub,打印ssh公钥
    • 再次尝试拉取代码
      • git clone ssh@…
  • 详细步骤见资料:link

报错:invalid author, does not match your user account

  • 背景:
    • 基于别人提交未合入的版本cherrypick下来,修改重新commit后,进行git push推送时出现。
  • 原因:
    • 可能是本地邮箱信息更换
    • 或者是在别人的commit信息(用的是对方邮箱账号)下再次提交
  • 解决:
    • git config -l,查看本地邮箱是否改变
    • 若改变,用以下指令修改重置:
      • git config --global user.name "your name"
      • git config --global user.email "your email"
    • 然后用指令:git commit --amend --reset-author,强制将本次commit重置为当前author
    • 最后用指令:git log,查看确认commit信息,author已变为本人,即可重新推送

猜你喜欢

转载自blog.csdn.net/qq_17256689/article/details/129309263