版本控制gitlab
1.GIT是分布式的,SVN不是:
这是GIT和其它非分布式的版本控制系统,例如SVN,CVS等,最核心的区别。需要做一点声明,GIT并不是目前第一个或唯一的分布式版本控制系统。还有一些系统,例如Bitkeeper, Mercurial等,也是运行在分布式模式上的。但GIT在这方面做的更好,而且有更多强大的功能特征。
GIT跟SVN一样有自己的集中式版本库或服务器。但GIT更倾向于被使用于分布式模式,也就是每个开发人员从中心版本库/服务器上chect out代码后会在自己的机器上克隆一个自己的版本库。可以这样说,如果你被困在一个不能连接网络的地方时,就像在飞机上,地下室,电梯里等,你仍然能够提交文件,查看历史版本记录,创建项目分支等。对一些人来说,这好像没多大用处,但当你突然遇到没有网络的环境时,这个将解决你的大麻烦。
同样,这种分布式的操作模式对于开源软件社区的开发来说也是个巨大的恩赐,你不必再像以前那样做出补丁包,通过email方式发送出去,你只需要创建一个分支,向项目团队发送一个推请求。这能让你的代码保持最新,而且不会在传输过程中丢失。github.com就是一个这样的优秀案例。
2.GIT把内容按元数据方式存储,而SVN是按文件:
所有的资源控制系统都是把文件的元信息隐藏在一个类似.svn,.cvs等的文件夹里。如果你把.git目录的体积大小跟.svn比较,你会发现它们差距很大。因为,.git目录是处于你的机器上的一个克隆版的版本库,它拥有中心版本库上所有的东西,例如标签,分支,版本记录等。
3.GIT分支和SVN的分支不同:
分支在SVN中一点不特别,就是版本库中的另外的一个目录。如果你想知道是否合并了一个分支,你需要手工运行像这样的命令*svn propget svn:mergeinfo*,来确认代码是否被合并。感谢Ben同学指出这个特征。所以,经常会发生有些分支被遗漏的情况。
然而,处理GIT的分支却是相当的简单和有趣。你可以从同一个工作目录下快速的在几个分支间切换。你很容易发现未被合并的分支,你能简单而快捷的合并这些文件。
常用的版本控制工具:
- gitlab
- subversion
4.部署gitlab
//安装git
[root@server ~]# yum -y install epel-release git
//安装依赖包
yum -y install curl openssh-server openssh-clients postfix cronie policycoreutils-python-utils
//启动postfix服务并设置开机自启
[root@server ~]# systemctl enable --now postfix.service
//下载gitlab的rpm包
[root@server ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.1.0-ce.0.el7.x86_64.rpm
//安装gitlab
[root@server ~]# rpm -ivh gitlab-ce-15.1.0-ce.0.el7.x86_64.rpm --nodeps
warning: gitlab-ce-15.1.0-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:gitlab-ce-15.1.0-ce.0.el7 ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=15-1
//修改配置文件
[root@server ~]# vim /etc/gitlab/gitlab.rb
external_url '192.168.159.100'
//重载配置文件并重启gitlab
[root@server ~]# gitlab-ctl reconfigure
[root@server ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 20168) 1s
ok: run: gitaly: (pid 20186) 0s
ok: run: gitlab-exporter: (pid 20203) 0s
ok: run: gitlab-kas: (pid 20205) 0s
ok: run: gitlab-workhorse: (pid 20214) 1s
ok: run: grafana: (pid 20224) 0s
ok: run: logrotate: (pid 20236) 1s
ok: run: nginx: (pid 20242) 0s
ok: run: node-exporter: (pid 20250) 0s
ok: run: postgres-exporter: (pid 20269) 1s
ok: run: postgresql: (pid 20296) 0s
ok: run: prometheus: (pid 20364) 1s
ok: run: puma: (pid 20377) 0s
ok: run: redis: (pid 20382) 0s
ok: run: redis-exporter: (pid 20395) 1s
ok: run: sidekiq: (pid 20410) 0s
//查看当前的gitlab版本
[root@server ~]# head -1 /opt/gitlab/version-manifest.txt
gitlab-ce 15.1.0
//破解管理员密码
[root@server ~]# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 15.1.0 (6bea4379525) FOSS
GitLab Shell: 14.7.4
Loading production environment (Rails 6.1.4.7)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = 'hwf1008...'
=> "hwf1008..."
irb(main):003:0> user.password_confirmation = 'hwf1008...'
=> "hwf1008..."
irb(main):004:0> user.save!
=> true
irb(main):005:0> exit
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-y79LjAGh-1663859059509)(C:\Users\hwf\AppData\Roaming\Typora\typora-user-images\image-20220922230210042.png)]
=> “hwf1008…”
irb(main):004:0> user.save!
=> true
irb(main):005:0> exit
[外链图片转存中...(img-y79LjAGh-1663859059509)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LvN5yJMu-1663859059510)(C:\Users\hwf\AppData\Roaming\Typora\typora-user-images\image-20220922230249098.png)]