安装

Linux安装Git

1
2
sudo yum install git
git --version

配置

长期保存登录凭证

1
git config --global credential.helper store

暂时缓存登录凭证

1
2
3
4
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'

默认储存15分钟可以自定义设置保存时间

命令

克隆

1
2
3
4
5
git clone <repository-url>
git clone <repository-url> <directory-name>

<repository-url> 是Git仓库的URL
<directory-name> 是本地创建并存放克隆代码的文件夹名称

拉取

1
git pull

暂存

1
git add

提交

1
2
3
4
5
6
提交已经 add 过的文件
git commit -m "the commit message"

会把所有跟踪且修改的文件 add 进来然后提交但不会add新建的文件
对于新建的文件还是需要先执行 add 命令后在提交
git commit -a "the commit message"

推送

1
git push

错误处理

💗💗 git 报错信息SSL certificate problem: certificate has expired 解决方案

1
2
3
4
5
使用git时报错错误信息如下
unable to access 'https:/xxxxxxx.git/': SSL certificate problem: certificate has expired

修改配置忽略SSL证书验证
git config --global http.sslVerify false

学习资源

  • 视频
    • 尚硅谷5h打通Git全套教程丨2021最新IDEA版 https://www.bilibili.com/video/BV1vy4y1s7k6
  • 书籍
    • 猴子都能懂的 Git 入门 https://backlog.com/git-tutorial/cn/
    • GitHub 漫游指南 https://github.phodal.com/
  • 文档
    • GitHub 官方文档https://docs.github.com/cn
  • 游戏
    • Learning Git Branchinghttps://learngitbranching.js.org/?locale=zh_CN