Ubuntu :gitee和gitlab安装和使用手册

git安装及使用说明

ps:可先登录gitee,创建空仓库,之后会出现操作提示,按照操作提示进行配置

安装git​

$ apt update; 
$ apt install git
#生成公钥key
$  [email protected]                         #查看是否有公钥
$  ssh-keygen -t rsa -C"[email protected]"         #获取公钥,邮箱为git的登录邮箱

##ps生成之后文件在用户目录下的.ssh文件下的id_rsa.pub

将获取到的公钥添加到gitee的设置中,位置如下:

选择文件配置git

Git 全局设置:

$ git config --global user.name "淡若初见"

$ git config --global user.email "12294077+[email protected]"

创建 git 仓库:

## ps: git config http.postBuffer 3060000(bit) 可扩大缓冲空间,提升上传速率

$ mkdir driver_ft                             #创建本地仓库文件
$ cd driver_ft
$ git init                                    #初始化
$ git clone "git的http/ssh链接"
​
#进入本地仓库文件 (clone后出现的文件夹)
​
$ cd xxx 
#创建新文件或者添加需要入库的文件
$ touch README.md
$ git add 文件路径及文件名                       #将文件提交到缓冲空间
​
$ git commit -m"first commit9"                #提交缓冲空间的文件,并包含一条描述内容
$ git remote add origin https://gitee.com/nxbing/driver_ft.git
$ git push -u origin "master"

gitlab安装及使用说明

#秘钥问题和gitee解决方式相同
$ git init 
$ git config --global user.name "nxbing"
$ git config --global user.email "[email protected]"
$ git config --global credential.helper wincred #存储凭证 (可用于输入一次用户密码后,不再输入)
$ git config http.postBuffer 5160000 #分配足额空间
$ git status    #查看所在分支,如果不同可以通过git checkout  分支名  的方式更改
$ git fetch origin nxbing-main-patch-43361(这个是分支名)   #同步远程服务器上的数据到本地
$ git checkout nxbing-main-patch-43361  #转换分支
$ ls         #查看是否拉取成功
# git clone "git的http/ssh链接"
$ git add 文件路径及文件名                                                                          #将文件提交到缓冲空间
$ git commit -m "first commit9"                                                               #提交缓冲空间的文件,并包含一条描述内容
$ git remote add origin https://gitee.com/nxbing/driver_ft.git
$ git push -u origin  "分支名"
#以后使用直接通过add、commit和push指令即可上传更新服务器仓库

猜你喜欢

转载自blog.csdn.net/NXBBC/article/details/129548116