====== GitLab 操作整理 ======
===== 重設 GitLab root 密碼 =====
* 參考 - https://honglung.pixnet.net/blog/post/201233991-gitlab-%E9%87%8D%E8%A8%AD-root-%E5%AF%86%E7%A2%BC
- 進入 gitlab console gitlab-rails console
- 找到 root user = User.find_by(username: 'root')
- 設定新密碼 user.password = '**new password**'
- 確認新密碼 user.password_confirmation = '**new password**'
- 將設定存檔 user.save
* 整體過程如下:
root@ct-gitlab ~# gitlab-rails console
Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
GitLab: 13.6.3 (857c6c6a6a9) FOSS
GitLab Shell: 13.13.0
PostgreSQL: 11.9
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.3)
irb(main):001:0>
irb(main):002:0> user = User.find_by(username: 'root')
=> #
irb(main):003:0> user.password = '**new password**'
=> "**new password**"
irb(main):004:0> user.password_confirmation = '**new password**'
=> "**new password**"
irb(main):005:0> user.save
Enqueued ActionMailer::MailDeliveryJob (Job ID: dc1d94bf-bafb-45xx-b2ae-084xx8b820a4) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#>]}
=> true
irb(main):006:0> exit
root@ct-gitlab ~#
===== git pull 記憶帳號密碼方式 =====
* 參考網址 - https://stackoverflow.com/questions/35942754/how-to-save-username-and-password-in-git
* 語法
git config --global credential.helper store
git pull 第一次輸入密碼後, 之後就不需要再輸入帳號密碼
* 如果之後有更改密碼, 就必須將 ~/.git-credentials 刪除重新再執行一次 git pull 設定帳號密碼
rm ~/.git-credentials
git pull
{{tag>gitlab}}