Hello World

行走即是圆梦,回望亦是前行。

0%

常见问题备忘

前言

这里简单记录下工作中遇到的常见问题备忘

git push提示HttpRequestException encountered,需要重新输入账号密码验证

让git for windows记住密码
提示信息:

1
2
fatal: HttpRequestException encountered.
发送请求时出错

解决方法:
进入git bash终端,输入如下命令:

1
$ git config --global credential.helper store

检查命令是否成功:

1
$ git config -l | grep credential credential.helper=store

或查看%HOME%目录下的.gitconfig文件,会新增如下配置:

1
2
[credential]
helper = store

重新开启git bash会发现git push时不用再输入用户名和密码,此时如果还是提示fatal: HttpRequestException encountered.,安装GCMW即可。

基于宝塔安装的github修改配置后重启服务nginx timeout

GitLab修改配置后nginx无法启动
提示信息:

1
2
3
4
5
6
7
8
$ gitlab-ctl restart
ok: run: gitlab-workhorse: (pid 31048) 0s
ok: run: logrotate: (pid 31057) 1s
timeout: down: nginx: 1s, normally up, want up
ok: run: postgresql: (pid 31499) 0s
ok: run: redis: (pid 31517) 0s
ok: run: sidekiq: (pid 31527) 0s
ok: run: unicorn: (pid 31533) 0s

解决方法:
修改nginx启动文件vi /opt/gitlab/sv/nginx/run,修改完成后重启服务即可

1
2
3
exec chpst -P /opt/gitlab/embedded/sbin/nginx -p /var/opt/gitlab/nginx
修改为
exec chpst -P /opt/gitlab/embedded/sbin/gitlab-web -p /var/opt/gitlab/nginx

fail: xxx: runsv not running

1
$ systemctl start gitlab-runsvdir.service

gitlab绑定域名后原有的仓库url地址ip修改为域名

GitLab服务器IP地址修改
绑定域名后新建的仓库,url显示域名,但原有的仓库url仍然显示ip

解决方法:
修改gitlab.yml配置文件:

/var/opt/gitlab/gitlab-rails/etc/gitlab.yml
1
2
3
4
5
6
7
8
9
10
11
12
production: &base
#
# 1. GitLab app settings
# ==========================

## GitLab settings
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
- host: 127.0.0.1
+ host: localhost
port: 9080
https: false

将host的ip修改为域名,执行gitlab-ctl restart重启Gitlab即可

git在windows上提交时会自动将LF替换成CRLF的问题

Git操作中crlf和lf冲突问题

CR:Carriage Return,\r,表示回车
LF:Linefeed,\n,表示换行
CRLF:Carriage Return & Linefeed,\r\n,表示回车并换行

平台换行
UNIX/LinuxLF
Mac OSLF
DOS/WindowsCRLF

Github上一些开源代码中是LF换行,但Windows平台使用的CRLF换行符。git默认配置了autocrlftrue,因此Windows下使用git默认所有代码LF都会被替换成CRLF,代码提交时显示0行差异,但仍会被认为是差异文件。
修改git全局配置,禁用git自动将LF转为CRLF

1
$ git config --global core.autocrlf false

宝塔gitlab修改管理员密码

【Gitlab】宝塔gitlab 修改管理员账号密码

  1. 切换目录:cd /opt/gitlab/bin
  2. 执行sudo gitlab-rails console production命令开始初始化密码
  3. irb(main):001:0>后通过u=User.where(id:1).first来查找与切换账号(User.all可以查看所有用户)
  4. 执行u.password='12345678'设置密码为12345678
  5. 执行u.save!进行保存
  6. 执行exit退出设置
  7. 通过账号root/12345678登录gitlab

linux登录出现-bash-4.2$的问题

linux 命令终端提示符显示-bash-4.2#解决方法
xshell的远程登录linux服务器,终端提示符显示的是-bash-4.2#而不是root@主机名的问题,问题原因:

1
用户目录下的配置文件丢失,具体文件为.bash_profile和.bashrc

解决方案:
从主默认文件重新拷贝一份配置文件到用户目录下:

1
2
cp /etc/skel/.bashrc /root/
cp /etc/skel/.bash_profile /root/

注销用户,重新登录即可恢复正常