关于git:常见的git命令和gitgithub问题

相干命令

  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

常见谬误

  1. 把本地的master分支重命名为main

    git branch -m master main
  2. 当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
    
  3. 当’credential-manager’ is not a git command

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

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

    问题剖析:呈现这个问题的最次要起因还是在于本地仓库和近程仓库实际上是独立的两个仓库。如果我之前是间接clone的形式在本地建设起近程github仓库的克隆本地仓库就不会有这问题了。

     git pull origin main --allow-unrelated-histories

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理