Git简单使用

1. 简介

   Git是一个分布版本控制系统;GitHub是一个开源项目托管平台,只支持Git作为唯一的版本库格式进行托管,于2008年正式上线。

2. Git安装与配置

   下载地址:http://git-scm.com/downloads or https://gitforwindows.org/
   安装完成后,可以使用命令行的 git 工具,另外还有一个图形界面的git项目管理工具, GitBash
   配置用户信息:打开gitbash,输入用户名和电子邮件
   $ git config --global user.name "XXX"
   $ git config --global user.email XXX@XX.com
   查看已有配置信息:$ git config --list
   生成密钥SSH key
   ssh-keygen -t rsa -C "your_email@youremail.com"
   将给定的路径下的id_rsa.pub文件中内容全部复制,粘贴到github的 Settings–>SSH and GPG keys–>New SSH key

3. 通过Git连接GitHub远程仓库

   远程仓库:Github新建一个仓库New repository,
   本地项目:建一个同名的文件夹,然后在该文件夹下Git Bash Here, 初始化仓库:
   git init
   建立连接
   git remote add origin git@github.com:yourName/repositoryname.git
   or git remote add origin https://github.com/yourName/repositoryname.git

4. 本地项目上传到GitHub

   查看当前状态git status
   将该目录下所有文件添加到仓库git add .
   提交到仓库git commit -m "此次提交的描述信息"
   将本地仓库的内容推送到远程仓库git push -u origin master

5. 删除远程仓库文件(本地文件不删)

   预览要删文件git rm -r -n --cached XXX
   删除文件git rm -r --cached XXX
   提交到本地仓库git commit -m "提交说明"
   推送到远程服务器git push origin master

6. 克隆项目
   本地建一个文件夹用来存放要克隆的项目
   git init
   git clone git@github.com:XXX/XXX.git

7. 报错处理
warning: LF will be replaced by CRLF … The file will have its original line endings in your working directory.
解决:
rm -rf .git
git config --global core.autocrlf false
git init
git add .

8. git push 没有权限
提出错误:Please make sure you have the correct access rights and the repository exists
解决: 检查本地.git/config 中的url, 如果是git@github.com:XXX/XXX.git,改为https://github.com/XXX/XXX.git

9. ssl
fatal: unable to access ‘https://github.com/wxler/test.git/’: OpenSSL SSL_connect: Connection was reset in connection to github.com:443
解决:
git config --global --unset http.sslBackend

或者

git config --global http.sslBackend “openssl”
git config --global http.sslCAInfo “D:\软件下载\Git\mingw64\ssl\cert.pem” (换成自己的git路径)

10. CApath:none
fatal: unable to access ‘https://github.com/XXX/code.git/’: error setting certificate verify locations: CAfile: ”“C:Program CApath: none
解决:
git config --system http.sslverify false

11. multiple values
error: cannot overwrite multiple values with a single value
Use a regexp, --add or --replace-all to change http.sslCAInfo.
解决:
git config --global --replace-all user.name “输入你的用户名”

12.error 10054
fatal: unable to access 'https://github.com/wxler/test.git/":openssl ssl_read: connection was reset, error 10054
解决
git config --global http.sslVerify false

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值