LEON BLOGLEON BLOG

GitLab

仓库、权限和 CI/CD。

示例命令请按实际环境替换主机、路径、账号、密码和命名空间。

git lfs 问题

gitlab邮箱配置

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "gitlab@xxx.cn"
gitlab_rails['smtp_password'] = "xxx"
gitlab_rails['smtp_domain'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_ssl'] = false
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['gitlab_email_from'] = "gitlab@xxx.cn"
user["git_user_email"] = "gitlab@xxx.cn"

gitlab迁移

  • gitlab备份
gitlab-rake gitlab:backup:create
  • gitlab 定制相关数据服务
# 停止相关数据连接服务
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
# 从1393513186编号备份中恢复
gitlab-rake gitlab:backup:restore BACKUP=1393513186
# 启动Gitlab
gitlab-ctl start

submodule

  • add submodule to project
git submodule add https://github.com/yyy/xxx.git DESTPATH
  • list submodule
git submodule
  • delete submodule
git submodule deinit
  • pull submodule: when git clone add parms --recursive
git clone https://github.com/xxx.git --recursive
  • if you forget add --recursive
    • git submodule update --init
    • git submodule update --init --recursive
  • update submodule
git submodule update --remote
  • change branch
git config submodule.xxx.branch dev

or git config -f .gitmodules submodule.xxx.branch dev

gitconfig 常用配置

[alias]
    ch = checkou
    st = status
    staust = 'gitst'
    cf = config
    ck = checkout
    ft = fetch
    fh = fetch
    br = branch
    brv = branch --v
    geturl = config --get remote.origin.url
    bs = bisect
    lg = log --graph --decorate --oneline --all
    cfg = config --global
    cfga = config --global alias.
    pull = pl
    pl = pull --rebase
    cm = commit -c HEAD
    ps = push
    lsr = ls-remote --heads
    udc = reset HEAD~
    ftg = fetch --tags
    am = commit -amend
    cmd = commit --amend
    rsh = reset HEAD~
    cmi = commit --interactive -c HEAD --reset-author
    i = --interactive
    rss = reset --soft
    rmc = rm --cached
    cp = cherry-pick
    cpx = cherry-pick -x
    bl = blame
    gk = gitk
    ltn = ls-tree -r HEAD~ --name-only
    lt = ls-tree -r HEAD~ --name-only
    ltng = ls-tree -r HEAD~ --name-only |grep
    lgd = log -p --full-diff
    bcm = "branch -a --contains "
    brc = branch -a --contains
    tagc = tag --contains