Git使用

pioner / 2023-05-03 / 原文

常规命令

配置

git config --list

上传本地代码文件到git仓库主要命令:

  1. git init (初始化仓库)

  2. git add . (这里的.表示添加所有文件,也可以自定义添加,到git 暂存区)

  3. git commit -m ‘添加的注释信息’   (暂存区内容添加到本地仓库)

  4. git remote add origin ‘url’

  5. git push -u origin master

查看关联的远程仓库 :git remote -v

遇到的问题

  1. fatal: unable to access ‘https://***.git/‘: OpenSSL SSL_read: Connection was reset, errno 10054

    一般是这是因为服务器的SSL证书没有经过第三方机构的签署,所以才报错。解除ssl验证后,再次git即可

git config --global http.sslVerify "false"
  1. error: src refspec xxx does not match any / error: failed to push some refs t

    是由于仓库名称不一样,导致远程和本地的仓库不能关联上,统一远程和本地的仓库名称即可。重命名命令: git branch -m oldBranchName newBranchName