gitlab基础命令之代码回滚
#:gitlab状态 root@ubuntu:~# gitlab-ctl status run: alertmanager: (pid 13305) 215965s; run: log: (pid 13081) 215991s run: gitaly: (pid 13180) 215968s; run: log: (pid 12160) 216098s run: gitlab-monitor: (pid 13241) 215968s; run: log: (pid 12828) 216009s run: gitlab-workhorse: (pid 13215) 215968s; run: log: (pid 12681) 216032s run: logrotate: (pid 75944) 144715s; run: log: (pid 12738) 216021s run: nginx: (pid 12690) 216028s; run: log: (pid 12706) 216027s run: node-exporter: (pid 13228) 215968s; run: log: (pid 12793) 216013s run: postgres-exporter: (pid 13320) 215965s; run: log: (pid 13141) 215983s run: postgresql: (pid 12311) 216093s; run: log: (pid 12408) 216090s run: prometheus: (pid 13271) 215967s; run: log: (pid 12955) 215997s run: redis: (pid 12080) 216105s; run: log: (pid 12112) 216102s run: redis-exporter: (pid 13258) 215967s; run: log: (pid 12911) 216002s run: sidekiq: (pid 12624) 216040s; run: log: (pid 12644) 216039s run: unicorn: (pid 12572) 216046s; run: log: (pid 12607) 216045s #:初始化环境(每次更改完配置都要执行此命令) root@ubuntu:~# gitlab-ctl reconfigure #:列出当前的所有组件 root@ubuntu:~# gitlab-ctl service-list #:重启gitlab(如果想单独重启某个服务,后面跟服务名) root@ubuntu:~# gitlab-ctl restart #:进入到postsql数据库 root@ubuntu:~# gitlab-rails dbconsole psql (9.6.11) Type "help" for help. gitlabhq_production=> gitlabhq_production=> \db List of tablespaces Name | Owner | Location ------------+-------------+---------- pg_default | gitlab-psql | pg_global | gitlab-psql | (2 rows) gitlabhq_production=> \help #:查看某个单独服务的日志 root@ubuntu:~# gitlab-ctl tail nginx #:克隆项目 root@ubuntu:/opt# git clone http://192.168.6.101/linux37/web1.git
#:Git命令使用 #:先在远程仓库克隆下来一段代码 root@ubuntu:/opt# git clone http://192.168.6.101/linux37/web1.git Cloning into 'web1'... Username for 'http://192.168.6.101': xiaoming Password for 'http://xiaoming@192.168.6.101': remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. root@ubuntu:/opt# ls gitlab web1 #:对代码进行修改 root@ubuntu:/opt# vim web1/index.html this is test page this is test page v2 root@ubuntu:/opt# cd web1/ #:先放到暂存区 root@ubuntu:/opt/web1# git add index.html #:在提交到本地存储 root@ubuntu:/opt/web1# git commit -m "v2" #:在提交到仓库 root@ubuntu:/opt/web1# git push #:也可以提交一个目录 #:先创建一个目录 root@ubuntu:/opt/web1# mkdir app #:在此目录下写点代码 root@ubuntu:/opt/web1# vim app/index.html this is directory v1 #:放到暂存区 root@ubuntu:/opt/web1# git add ./* #:提交到本地仓库 root@ubuntu:/opt/web1# git commit -m "v1" #:提交到远程仓库 root@ubuntu:/opt/web1# git push #:当刚提交到暂存区的时候可以用Git status查看到 root@ubuntu:/opt/web1# git add index.html root@ubuntu:/opt/web1# git staus git: 'staus' is not a git command. See 'git --help'. The most similar command is status root@ubuntu:/opt/web1# git status On branch master Your branch is up to date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: index.html #:查看相关日志 root@ubuntu:/opt/web1# git log commit 416ab98610aaa8939f48ee43be46598d75efa7ab (HEAD -> master, origin/master, origin/HEAD) Author: xiaoming <316428921@qq.com> Date: Sun Sep 29 10:46:42 2019 +0800 v3 #:这个就是commit注释的内容 commit 42785a48c2f235df7276ed15a2bfd14a46e1e023 #:此处是tag号 Author: xiaoming <316428921@qq.com> Date: Sun Sep 29 10:40:23 2019 +0800 v1 #:代码回滚(一个 ^ 就是一个版本)注:回滚的时候只能在未提交到仓库的时候回滚 root@ubuntu:/opt/web1# git reset --hard HEAD^ #:查询tag号 root@ubuntu:/opt/web1# git reflog 416ab98 (HEAD -> master, origin/master, origin/HEAD) HEAD@{0}: pull: Fast-forward 3d91a05 HEAD@{1}: reset: moving to HEAD^ root@ubuntu:/opt/web1# git reset 53082b0 #:回滚的时候可以指定tag号回滚 #:查看所有分支 root@ubuntu:/opt/web1# git branch * master #:指定分支克隆 root@ubuntu:/opt# git clone -b develop http://192.168.6.101/linux37/web1.git #:切换分支 root@ubuntu:/opt/web1# git checkout master Branch 'master' set up to track remote branch 'master' from 'origin'. Switched to a new branch 'master' root@ubuntu:/opt/web1# git checkout Your branch is up to date with 'origin/master'