欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用gitlab在服務(wù)器上搭建私服git倉庫并上傳項(xiàng)目的操作方法

 更新時間:2023年12月22日 09:04:11   作者:碧藍(lán)幻想  
這篇文章主要介紹了使用gitlab在服務(wù)器上搭建私服git倉庫,并且上傳項(xiàng)目,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

官網(wǎng):The DevSecOps Platform | GitLab

1.安裝gitlab軟件:

安裝相關(guān)依賴:

yum install -y policycoreutils policycoreutils-python openssh-server open-clients postfix ca-certificates
# ca-certificates: 不安裝下載gitlab包報(bào)錯--no-check-certificate

設(shè)置postfix開機(jī)自啟,并啟動,postfix支持gitlab發(fā)信功能

systemctl start postfix && systemctl enable postfix

下載給gitlab包

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.4.2-ce.0.el7.x86_64.rpm

安裝rpm包:

rpm -ivh gitlab-ce-12.4.2-ce.0.el7.x86_64.rpm

修改gitlab的配置:/etc/gitlab/gitlab.rb

# 修改gitlab訪問地址和端口,默認(rèn)為80,我們改為82
sed -i "s/^external_url.*/external_url 'http:\/\/192.168.66.201:82'/" /etc/gitlab/gitlab.rb
# 第一次修改,nginx監(jiān)聽端口
sed -i "s/^# nginx\['listen_port'\].*/nginx\['listen_port'\] = 82/" /etc/gitlab/gitlab.rb
# 后面的修改,nginx監(jiān)聽端口
sed -i "s/^nginx['listen_port'].*/nginx['listen_port'] = 82/" /etc/gitlab/gitlab.rb
# 重新加載配置
gitlab-ctl reconfigure

重啟gitlab服務(wù):

gitlab-ctl restart

登陸頁面:http://192.168.174.201:82,修改root用戶密碼

使用root用戶登陸:

2.配置ssh公鑰:

ssh-keygen -t rsa -b 1024 -C "用戶名/郵箱"
# 如果不指定用戶名和郵箱,將默認(rèn)使用主機(jī)的用戶名和主機(jī)名
# ssh-keygen - 生成、管理和轉(zhuǎn)換認(rèn)證密鑰,t制定類型
# RSA
# window:C:/用戶/user/.ssh/id_rsa.pub公鑰文件,linux:~/.ssh/id_rsa.pub公鑰文件
cat ~/.ssh/id_rsa.pub

3.安裝和配置git:

安裝:

yum install -y git

配置:

git config --global user.name "qv123"
git config --global user.email "qv1095322098@163.com"
# 查看
git config --global user.name
git config --global user.email

4.上傳項(xiàng)目:

1.方式一:創(chuàng)建本地項(xiàng)目推送

初始化項(xiàng)目。將項(xiàng)目添加到工作區(qū),或者直接拉取空倉庫:

cd ~/my_hexo && git init

添加遠(yuǎn)程倉庫路徑:倉庫地址是服務(wù)器IP

git remote add origin git@192.168.174.201:qv123_group/my_hexo.git
# origin遠(yuǎn)端名稱
# 查看命令幫助:git remote -help

查看遠(yuǎn)程倉庫得名稱和地址:

git remote -v show

將項(xiàng)目從工作區(qū)添加到暫存區(qū):

git add .

將項(xiàng)目從暫存區(qū)提交到本地倉庫:(這里必須配置用戶名和郵箱地址)

git commit -m "one commit"

查看本地分支:

git branch

拉取一下遠(yuǎn)程的空倉庫:

# 最好拉取一下空倉庫,不然可能導(dǎo)致推送錯誤
git pull -u origin master

# 報(bào)錯
To git@192.168.174.201:qv123_group/my_hexo.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@192.168.174.201:qv123_group/my_hexo.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[root@gitlab-server qv1234.github.io-master]# git pull --rebase origin
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
?
Please make sure you have the correct access rights
and the repository exists.

推送到遠(yuǎn)程倉庫:

git push -u origin master
# master是分支

2.方式二:(推薦

直接克隆空倉庫:

git clone git@192.168.174.201:qv123_group/my_hexo.git
cd my_hexo

查看遠(yuǎn)程倉庫得名稱和地址:

[root@gitlab-server my_hexo]# git remote -v show
origin  git@192.168.174.201:qv123_group/my_hexo.git (fetch)
origin  git@192.168.174.201:qv123_group/my_hexo.git (push)

將項(xiàng)目從工作區(qū)添加到暫存區(qū):

git add . --all

將項(xiàng)目從暫存區(qū)提交到本地倉庫:(這里必須配置用戶名和郵箱地址)

git commit -m "one commit"

查看本地分支:

git branch

推送到遠(yuǎn)程倉庫:

git push -u origin master
# master是分支

到此這篇關(guān)于使用gitlab在服務(wù)器上搭建私服git倉庫,并且上傳項(xiàng)目的文章就介紹到這了,更多相關(guān)gitlab在服務(wù)器上搭建私服git倉庫內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論