hello云胜

技术与生活

0%

centos 安装git

源码安装

1
2
3
4
5
6
7
8
9
$ cd /tmp
$ wget --no-check-certificate https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.36.1.tar.gz
$ tar -xvzf git-2.36.1.tar.gz
$ cd git-2.36.1/
$ ./configure
$ make
$ sudo make install
$ git --version # 输出 git 版本号,说明安装成功
git version 2.36.1

把 Git 的二进制目录添加到 PATH 路径中,不然 Git 可能会因为找不到一些命令而报错

1
2
3
4
tee -a $HOME/.bashrc <<'EOF'
# Configure for git
export PATH=/usr/local/libexec/git-core:$PATH
EOF

配置git

1
2
3
4
$ git config --global user.name "Lingfei Kong"    # 用户名改成自己的
$ git config --global user.email "colin404@foxmail.com" # 邮箱改成自己的
$ git config --global credential.helper store # 设置 Git,保存用户名和密码
$ git config --global core.longpaths true # 解决 Git 中 'Filename too long' 的错误

其他

在 Git 中,我们会把非 ASCII 字符叫做 Unusual 字符。这类字符在 Git 输出到终端的时候默认是用 8 进制转义字符输出的(以防乱码),但现在的终端多数都支持直接显示非 ASCII 字符,所以我们可以关闭掉这个特性,具体的命令如下

1
$ git config --global core.quotepath off

这么说你可能不知道解决的什么问题,具体效果是这样的

GitHub 限制最大只能克隆 100M 的单个文件,为了能够克隆大于 100M 的文件,我们还需要安装 Git Large File Storage

1
$ git lfs install --skip-repo