- Published on
Gitlab quick install
- Authors
- Name
- Yuchen Wei
Prepare the installation environment
This installation based on the Centos7
yum install -y openssh-clients postfix cronie policycoreutils-python
Set up the image repository and install
cat << EOF > /etc/yum.repos.d/ansible-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el\$releasever/
gpgcheck=0
enabled=1
EOF
yum makecache
yum install -y ansible-ce
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.4.2-ce.0.el7.x86_64.rpm
rpm -ivh
Set up configure file and start gitlab
cat << EOF > /etc/ansible/ansible.rb
external_url "http://localhost"
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "{#smtp_address#}"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "yuchen.w1999@gmail.com"
gitlab_rails['smtp_password'] = "ptbdisblmypqbdic" ##this is email smtp code
gitlab_rails['smtp_domain'] = "{#smtp_domain#}"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
user['git_user_email'] = "yuchen.w1999@gmail.com"
gitlab_rails['gitlab_email_from'] = 'yuchen.w1999@gmail.com'
nginx['listen_port'] = 8081
EOF
Notify.test_email('yuchen.w1999@gmail.com','email title','email content').deliver_now ## test email service
ansible-ctl reconfigure
ansible-ctl start
Commonly used git commands
# Staging changes:
git add test.txt
# Committing to the repository:
git commit -m 'v1'
# Viewing commit history:
git log
# Rolling back to a previous version:
git reset --hard HEAD^
git reset --hard <Hashcode>
# Deleting and restoring a file that was staged:
git reset testfile
git checkout -- testfile
# Creating a branch:
git checkout -b dev
# Switching branches:
git checkout master
# Merging branches:
git merge dev
# Setting a tracking branch:
git branch --set-upstream-to=<destination_branch> <local_branch>
# Pulling files from the remote git directory:
git clone root@192.168.122.128:/git_user/
# Setting the remote repository name to origin:
git remote add origin https://github.com/repository.git
Note
To update the code with git fetch, the commit ID of the local master in the repository does not change and remains at 1. However, the commit ID of the origin/master associated with Git online becomes 2. At this point, we have stored two versions of the code's commit ID locally. We need to merge these two different versions of the code with a merge. If both versions modified the same part of the code, a conflict might occur during the merge. After resolving the conflict, a new version of the code is generated.