GitLab: Web-based Git repository manager

Install
http://www.panticz.de/install-gitlab

# restart gitlab
gitlab-ctl restart

# git home directory
/var/opt/gitlab

Reset admin password
gitlab-rails console production
u = User.where(id: 1).first
u.password = 'secret'
u.password_confirmation = 'secret'
u.save!

backup
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md
# full backup
gitlab-rake gitlab:backup:create

# backup without reposiories
sudo gitlab-rake gitlab:backup:create SKIP=repositories

# backup target
ls -l /var/opt/gitlab/backups

restore
sudo gitlab-rake gitlab:backup:restore force=yes
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md

Send email via SMTP
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/smtp.md

Create backup
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop nginx

sudo gitlab-rake gitlab:backup:create

commands
gitlab-rake db:migrate
gitlab-ctl reconfigure
gitlab-ctl restart
sudo gitlab-ctl tail
sudo gitlab-ctl tail nginx
gitlab-rake cache:clear
gitlab-ctl hup unicorn
sudo gitlab-rake gitlab:check
sudo cat /var/log/gitlab/gitlab-rails/production.log
sudo gitlab-rails console
sudo gitlab-ctl status

sudo gitlab-rake gitlab:backup:restore [-v --trace]

# update
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/update.md

# http://www.mikeobrien.net/blog/setting-up-gitlab-with-active-directory-and-self-signed-cert/
http://www.mikeobrien.net/blog/setting-up-gitlab-with-active-directory-and-self-signed-cert/

# self signed certificate ?
https://futurestud.io/blog/how-to-run-gitlab-with-self-signed-ssl-certificate/

User management CLI
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/user_management.md

Reset GitLab admin password
http://doc.gitlab.com/ce/security/reset_root_password.html

Logs
tail -f /var/log/gitlab/gitlab-rails/*.log
cat /var/log/gitlab/gitlab-rails/application.log

Fix: Could not authorize you from LDAP because "Undefined method `persisted?' for ...
-- login to Gitlab DB (MySql)
mysql -u gitlab gitlabhq_production -p
select email from users where username like 'foo';
update users set extern_uid = '' where username = 'foo';

Database
-- login to DB (Omnibus Postgres Database)
sudo gitlab-rails dbconsole

# OR (old?)
su gitlab-psql -c "/opt/gitlab/embedded/bin/psql gitlabhq_production"
select extern_uid from identities where extern_uid like '%foo%';
delete from identities where extern_uid like '%foo%';
commit

check if postgress is running
sudo netstat -anp | grep 5432

Change logo
http://jo-ke.name/wp/?p=156&lang=de

/opt/gitlab/embedded/service/gitlab-rails/app/helpers/appearances_helper.rb
/opt/gitlab/embedded/service/gitlab-rails/app/views/layouts/devise.html.haml
add
%img{:src => "/assets/logo.svg"}

copy image to
/opt/gitlab/embedded/service/gitlab-rails/public/assets/logo.svg

# disable migration after update
sudo touch /etc/gitlab/skip-auto-migrations

Markdown
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/markdown/markdown.md#url-auto-linking

Links
https://www.omniref.com/github/gitlabhq/omnibus-gitlab/7.1.1.omnibus
https://gitlab.com/gitlab-org/cookbook-gitlab/blob/master/attributes/default.rb

binary
/opt/gitlab/embedded/bin/git

grep
cd /var/opt/gitlab/git-data/repositories/foo
for REPO in $(ls); do
(cd ${REPO}; /opt/gitlab/embedded/bin/git grep bar HEAD)
done

# enable GitLab SSL
# https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md
sed -i 's/http/https/g' /etc/gitlab/gitlab.rb

sudo mkdir -p /etc/gitlab/ssl
sudo chmod 700 /etc/gitlab/ssl

# create self signed key
openssl \
req \
-x509 \
-newkey rsa:2048 \
-sha256 \
-nodes \
-days 365 \
-keyout /etc/gitlab/ssl/$(hostname -f).key \
-out /etc/gitlab/ssl/$(hostname -f).crt \
-subj "/C=DE/ST=NRW/L=Koeln/O=Example Inc/OU=IT/CN=$(hostname -f)/emailAddress=info@$(hostname -f)"

cat <> /etc/gitlab/gitlab.rb
external_url "https://$(hostname -f)"
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/letsencrypt/live/$(hostname -f)/fullchain.pem"
nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/$(hostname -f)/privkey.pem"
EOF

sudo gitlab-ctl reconfigure

GitLab markdown
https://docs.gitlab.com/ee/user/markdown.html