首页
文章
登录
登录
注册
忘记密码
反馈
Git操作记录
lyj
Published 2023-12-27
586
分享
[TOC] # 操作 ## 删除分支 ```shell # 切换到master分支 git checkout dev # 删除本地分支 git branch -d userstory # 强制删除本地分支 git branch -D userstory # 删除远程分支 git push origin --delete userstory ``` ## 修改gitignore后生效 ``` git rm -r --cached . # 然后可进行正常操作 git add . git commit -m "xxx" ``` ## Gitlab备份迁移: ### 备份 启动gitlab的docker镜像,进入容器内部: `docker exec -it gitlab-ce bash` ```shell # 运行备份数据到命令,备份文件默认在/var/opt/gitlab/backups ,如果没有请查找/etc/gitlab/gitlab.rb backup相关配置 gitlab-rake gitlab:backup:create #有两个文件需要手工备份 #gitlab.rb路径:/etc/gitlab/gitlab.rb #gitlab-secrets.json路径:/etc/gitlab/gitlab-secrets.json #备份文件名称为1671601005_2022_12_21_12.9.4_gitlab_backup.tar ``` ### 恢复(迁移) > 迁移时,新的gitlab版本必须和旧的gitlab版本一致。 把旧服务器的备份文件 例如 1671601005_2022_12_21_12.9.4_gitlab_backup.tar 放到 对应的文件夹内 ```shell cd /usr/local/gitlab cd backup mv xxx/1671601005_2022_12_21_12.9.4_gitlab_backup.tar . docker exec -it gitlab_web_1 /bin/bash gitlab-rake gitlab:backup:restore BACKUP=1671601005_2022_12_21_12.9.4 #注意 恢复时需要指定此前备份的名称(但是不需要写名称的_gitlab_backup.tar后缀) #从旧服务器上复制/etc/gitlab/gitlab.rb 和 /etc/gitlab/gitlab-secrets.json 到容器中 #退出容器,重启容器 ``` 注意: 如果出现权限问题,在容器内部设置backups文件夹以及子内容权限即可 `chown -R git:root backups` # Gitlab错误解决 ## OpenSSL: : Cipher::CipherError () > 日志文件为: srv/gitlab/logs/gitlab-rails/production.log ```shell # 进入docker容器 docker exec -it gitlab-ce bash # 进入gitlab 终端 gitlab-psql -d gitlabhq_production # 指定命令 UPDATE projects SET runners_token = null, runners_token_encrypted = null; ``` ## 项目中webhooks打不开报500错误 > 日志文件为: srv/gitlab/logs/gitlab-rails/production.log 报错日志如下 ``` Completed 500 Internal Server Error in 15ms (ActiveRecord: 2.1ms | Elasticsearch: 0.0ms | Allocations: 12260) ActionView::Template::Error (): 1: %li 2: .row 3: .col-md-8.col-lg-7 4: %strong.light-header= hook.url 5: %div 6: - hook.class.triggers.each_value do |trigger| 7: - if hook.public_send(trigger) -- Started GET "/root/php/hooks" for 192.168.0.20 at 2022-04-14 13:05:45 +0800 Processing by Projects::HooksController#index as HTML ``` **解决** 1. 通过web页面,获取project_id  2. 通过project_id,查找出hook_id ``` 进入gitlab命令行 # gitlab-rails db //会得到hook_id gitlabhq_production=> select id from web_hooks where project_id=30; ``` 3. 将存在的hook_id清除掉 ``` //删除project_id=30的所有记录 gitlabhq_production=> delete from web_hooks where project_id=30; UPDATE 4 gitlabhq_production=> ``` 4. 最后,刷新webhooks页面即可
分享
Share this article
关闭
Scan the QR code on your device to read or share instantly.
Copy
Use the link above to share with your team or friends.
暂无评论
请登录后评论
新评论
删除
关闭
提交