一、本地创建系统用户
1.创建zhangsan用户
代码语言:shell复制[root@k8s gitlab]# useradd zhangsan
[root@k8s gitlab]# passwd zhangsan
Changing password for user zhangsan.
New password:
BAD PASSWORD: The password fails the dictionary check - it is too simplistic/systematic
Retype new password:
passwd: all authentication tokens updated successfully.
[root@k8s gitlab]# su - zhangsan
2.创建数据存放目录
代码语言:shell复制[zhangsan@k8s ~]$ mkdir -p ~/zhangsan/gitlab
[zhangsan@k8s ~]$ cd zhangsan/gitlab/
[zhangsan@k8s gitlab]$
二、git用户信息配置
1.git信息配置
代码语言:shell复制1.配置该git的使用者
git config --global user.name "zhangsan"
2.配置git使用者的邮箱
git config --global user.email "zhangsan@qq.com"
3.使文本高亮
git config --global color.ui true
2.查看git信息状态
代码语言:shell复制[zhangsan@k8s gitlab]$ cat ~/.gitconfig
[user]
name = zhangsan
email = zhangsan@qq.com
[color]
ui = true
三、下载代码版本库
1.进行证书忽略
代码语言:shell复制git config --global http.sslVerify false
2.下载版本库
代码语言:shell复制[zhangsan@k8s gitlab]$ git clone https://192.168.1.8:8443/it-group01/it-items.git
Cloning into 'it-items'...
Username for 'https://192.168.1.8:8443': zhangsan
Password for 'https://zhangsan@192.168.1.8:8443':
warning: You appear to have cloned an empty repository.
3.进行文件的版本提交系列操作
代码语言:shell复制[zhangsan@k8s gitlab]$ cd it-items/
[zhangsan@k8s it-items]$ git add README.md
fatal: pathspec 'README.md' did not match any files
[zhangsan@k8s it-items]$ touch README.md
[zhangsan@k8s it-items]$ git add README.md
[zhangsan@k8s it-items]$ git commit -m "1.0-zhangsan carte a file for README.md"
[master (root-commit) 9dcfd68] 1.0-zhangsan carte a file for README.md
1 file changed, 0 insertions( ), 0 deletions(-)
create mode 100644 README.md
[zhangsan@k8s it-items]$ git log --oneline
9dcfd68 1.0-zhangsan create a file for README.md
四、本地客户端ssh连接gitlab仓库免密
1.本地电脑生成密钥
代码语言:shell复制 ssh-keygen -t rsa
2.查看公钥信息
代码语言:shell复制ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIPoVZkyzMnQ1PPzwBm1Cu1COzbvoXcPR/PH5cgPa9aiJMOGWUevknFh6Rj67v 0ju piZUsPDcNBhAXHlhzfiQF aToKLIK5RnwVmiuQF2notc484yYCKlIe/SUNOb3PSU1wAoXBzB xD0kIIhVwoC6mdpadPCuQr5gWlzSJdKGrU TC4boaQP7wdJ8EhhJgTrt6Emki7lm aKMzPojBek3HnWb qRbBDmKCBnF4XjIjogQIsWh7OHs9ss9rY1kRhyx/28lFeSd7CVGBSHPFnm ghhKAjom1vu5BAwrThBcP0J7MXDA/7/1P3tsTa34D0CTeEBr6xuN4g6In3T9t zhangsan@k8s
3.将公钥拷贝到gitlab
五、本地仓库文件同步到远程gitlab仓库
1.切换origin
代码语言:shell复制git remote rename origin old-orign
2.连接到远程仓库
代码语言:shell复制git remote add origin https://192.168.1.8:8443/it-group01/it-items.git
3.上传文件
代码语言:shell复制git push -u origin master
4.查看远程版本仓库信息
代码语言:shell复制git remote -v
5.删除远程仓库信息
代码语言:shell复制git remote remove old-orign
git remote remove origin
我正在参与2023腾讯技术创作特训营第三期有奖征文,组队打卡瓜分大奖!