标准Gitlab命令行操作指导

gitlab是一个分布式的版本仓库,总比只是一个本地手动好些,上传你的本地代码后后还能web GUI操作,何乐不为?

贴上刚刚搭建的gitlab,看看git 如何操作标准命令行操作指导

1.命令行操作指引

yum install git
Command line instructions
You can also upload existing files from your computer using the instructions below.


Git global setup
git config --global user.name "alex"
git config --global user.email "your@example.com"

Create a new repository
git clone https://gitlab.example.com/alex/test-repo.git
cd test-repo
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Push an existing folder
cd existing_folder
git init
git remote add origin https://gitlab.example.com/alex/test-repo.git
git add .
git commit -m "Initial commit"
git push -u origin master

Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.example.com/alex/test-repo.git
git push -u origin --all
git push -u origin --tags

 

PS:

git for linux使用

windows上使用Git bash教程

 

2.deveolper创建分支与提交合并分支

git -c http.sslverify=false clone https://gitlab.example.com/root/test-repo.git

cd test-repo
git checkout -b release-1.0
#操作完成后,本地添加并提交修改后的版本分支
git add .
git commit -m"release-1.0"
git-c http.sslVerify=false push origin release-l.0

 

然后gitlab上提交 Create merge request,同时提示Assignee给lead看就完成deveploer的操作了,等待上级的确认操作即可

 

 

 

 

 

 

[root@vps ~]# gitlab-ctl stop
ok: down: alertmanager: 1s, normally up
ok: down: gitaly: 0s, normally up
ok: down: gitlab-exporter: 0s, normally up
ok: down: gitlab-workhorse: 1s, normally up
ok: down: grafana: 0s, normally up
ok: down: logrotate: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: node-exporter: 1s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 0s, normally up
ok: down: redis: 0s, normally up
ok: down: redis-exporter: 1s, normally up
ok: down: sidekiq: 0s, normally up
ok: down: unicorn: 0s, normally up
[root@vps ~]#

 

 

# gitlab 命令行解锁账号
/data/gitlab/bin/gitlab-rails console
user = User.find_by(email:'xxx@example.com')
user.unlock_access

 

Q1  fatal: refusing to merge unrelated histories

因为两个根本不相干的 git 库, 一个是本地库, 一个是远端库, 然后本地要去推送到远端, 远端觉得这个本地库跟自己不相干, 所以告知无法合并

解决方案一

git clone远程仓库到本地,将需要推送的内容放到该仓库下 , 然后提交上去 , 这样算是一次update操作

使用强制命令

git pull origin master --allow-unrelated-historie

git push -u origin master

 

PS Linux 环境下安装 GitLab 与配置

gogs 安装

 

posted @ 2020-01-28 14:22  AlexG  阅读(1096)  评论(0编辑  收藏  举报