1.创建gitlab远程仓库项目,选择输入,再点击Create project,就ok了(如图)
在这里插入图片描述
2.在本地项目里右击,选择Git Bash Here,打开git命令面板,输入以下命令,生成gitlab的密钥

//使用第一种出现管理员权限问题时,则使用第二种方法
ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitlab -C "你的邮箱"  //第一种方法
ssh-keygen -t rsa -C "你的邮箱"  			//第二种方法

3.完成后会在C:\Users\xxx.ssh/目录下生成以下文件

//对应第一种呈现的文件内容
id_rsa
id_rsa.pub
//对应第二种呈现的文件内容
id_rsa.gitlab
id_rsa.gitlab.pub

4.打开id_rsa.gitlab.pub文件,全选复制里面的文本
再打开gitlab–settings–SSH Keys(如图),将复制的密钥粘贴到文本框中
点击Add Key,就ok了
在这里插入图片描述
5.在本地项目里右击,选择Git Bash Here,打开git命令面板,输入git init

git init

6.本地关联远程仓库

$ git remote add origin https://gitlab.com/xxx/xxx.git

7.从远程仓库拉取最新代码

git pull origin master 

8.本地add

git add . 

9.本地commit

git commit -m 'init'

10.本地push

git push origin master

遇到问题:
1.git pull时出现如图时,原因是密码输入错误
在这里插入图片描述
解决方法:
输入命令 git config --system --unset credential.helper (清除用户名与密码)

git config --system --unset credential.helper

2.git add 出现如图时,原因是路径中存在 / 的符号转义问题,false就是不转换符号默认是true,相当于把路径的 / 符号进行转义,这样添加的时候就有问题
文件路径存在/的符号

在这里插入图片描述
解决方法:
输入命令 git config --global core.autocrlf false 将默认为true的转换符号更改为false

git config --global core.autocrlf false

参考链接:
1.gitlab上先创建项目并存在文件,本地代码如何提交到该仓库
2.remote: http basic: access denied fatal: authentication failed for '‘解决办法
3.GitLab中配置SSH key
4.git添加Github、Gitee、Gitlab秘钥
5.gitlab创建项目,并且将本地项目推送到远程仓库
6.使用gitlab创建项目和添加成员,并提交本地代码至gitlab远程仓库
7.解决Permission denied, please try again问题

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐