白日依山尽,黄河入海流。欲穷千里目,更上一层楼。 -- 唐·王之涣

gitlab http方式存储密码(含Mac)

1、优先配置 username

1
2
git config --global user.email "你的git的注册邮箱"
git config --global user.user"你的git用户名"

2、配置存储密码

官网参考文档 https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage

image-20221014163431858

1、默认是每次需要输入用户名和密码的

1
2
3
4
5
# 每次提示需要 用户名和密码
git clone http://gitlab.xxx.com/groupname/projectname.git

# 可以在URL中直接指定账号密码(不建议)
git clone http://your-gitname:your-gitpasswd@gitlab.xxx.com/groupname/projectname.git

2、配置cache,默认是15分钟,当然也可以指定缓存时间

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

3、store 方式存储,是文件的形式存储在磁盘上

1
2
# 这条命令会在用户目录生成 .git-credentials 文件
git config --global credential.helper store

4、如果使用的是Mac系统 那么使用 osxkeychain 存储

1
2
# Mac存储在keychain
git config --global credential.helper osxkeychain

5、特殊的Windows也可以使用一种叫做Git Credential Manager, 可以独立安装,或者是在 gitbash中继承

3、其他配置

1
2
3
4
5
6
7
8
9
# 1、移除ssh方式 (需要进入对应的项目目录下)
git remote rm origin

# 2、然后增加https
# URL中配置账号和密码(不建议)
git remote add origin http://yourname:password@git.oschina.net/name/project.git

# 使用本地存储的账号密码
git remote add origin http://git.oschina.net/name/project.git

如果觉得文章对你有用,请不吝点赞和关注公众号搜索 全栈运维 或者 DailyJobOps

个人博客 http://blog.colinspace.com/

知乎平台 https://www.zhihu.com/people/colin-31-49

CSDN平台 https://blog.csdn.net/eagle5063

简书平台 https://www.jianshu.com/u/6d793fbacc88

gitlab报错 - RPC failed

导语

部门使用的代码管理仓库是gitlab,随着业务发展,代码量也越来越大,到目前已经大于100M,今天新入职员工全量拉取代码时候报错,查找原因是因为代码仓库太大导致拉取超时。 这里记录下处理过程


报错

fatal: early EOF
fatal: The remote end hung up unexpectedly
fatal: index-pack failed
error: RPC failed; result=18, HTTP code = 200

解决

因为这边使用的docker搭建的gitlab,处理方式有点不同
必须先进入到gitlab容器中去操作,重启 gitlab 也必须是进入到docker 容器中重启,
否则从服务器直接重启容器会导致配置丢失,恢复成默认值

nginx client_max_body_size

之前修改过gitlab前端nginx的 client_max_body_size 大小,确保上传下载超大文件的可能性

vi /etc/nginx/nginx.conf
client_max_body_size 50M;

## check and reload nginx config
nginx -t
nginx -s reload

gitlab timeout

## need to enter gitlab container firstly
## then edit the config
vi config/unicorn.rb
timeout 300

## then restart gitlab in container
## remember that must be in container
/etc/init.d/gitlab restart

git http.postBuffer

另外建议也修改下本地 http.postBuffer 参数

## modify in commandline 
git config --global http.postBuffer 524288000

## check config list 
git config --list

最后重新拉取,没有问题


公众号: DailyJobOps DailyJobOps