常见的git命令和git->github错误
阅读原文时间:2022年07月01日阅读:1
  1. git remote

     git remote add origin xxx (xxx为仓库链接)

    给这个链接取一个名字,为origin

  2. git pull

    git pull <远程主机名>  <远程分支名>:<本地分知名>
  3. git push

    git push origin main
  4. 删除一个远程仓库

    git remote rm xxx(仓库名)
  5. 修改一个远程仓库链接

    git remote set-url origin <remote-url>
  6. 查询仓库

    git remote -v
  7. 把本地的master分支重命名为main

    git branch -m master main
  8. 当Failed to connect to 127.0.0.1 port 1080

    // 首先,查一下当前全局的 http 代理:
    git config --global http.proxy
    // 如果有代理,就取消
    git config --global --unset http.proxy
    
    // 再查 https 的代理:
    git config --global https.proxy
    // 同样的,有就取消
    git config --global --unset https.proxy
  9. 当'credential-manager' is not a git command

    git config --global credential.helper wincred
  10. 当OpenSSL SSL_read: Connection was reset

    git config --global http.sslVerify "false"
  11. 当fatal: refusing to merge unrelated histories

    问题分析:出现这个问题的最主要原因还是在于本地仓库和远程仓库实际上是独立的两个仓库。假如我之前是直接clone的方式在本地建立起远程github仓库的克隆本地仓库就不会有这问题了。

     git pull origin main --allow-unrelated-histories