git 上传文件到gitlab

简介: git 上传文件到gitlab

1.登录


首先进入需要上传的文件夹,鼠标右键点击Git Bash Here

#输入用户名、邮箱
git config --global user.name "Your Name"
git config --global user.email "xxx@qq.com"
//查看设置
git config --list

2.生成公共密钥

ssh-keygen -t rsa -C "xxx@qq.com"

生成密钥的位置在:

C:\Users\Administrator\.ssh

17.png

打开 id_rsa.pub,复制密钥,粘贴到下图中,点击增加密钥。

18.png

3.配置路由到hosts文件


当你出现报错:

ssh: Could not resolve hostname xxx.com: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

19.png

解决:


在C:\Windows\System32\drivers\etc中,配置hosts文件


右击hosts文件,并以记事本格式打开。然后在文件最后一行添加如下内容:


xxx.xxx.xxx github.com


4.初始化


输入git init,初始化git相关配置文件


git init


5、设置本地与远程仓库的链接


输入git remote add origin *你的远程仓库地址*,设置本地与远程仓库的链接


git remote add origin http://gitlabxxxxx.git


如果不设置会出现:

fatal: 'origin' does not appear to be a git repository fatal: Could not read from remote repository.

6、拉取远程仓库


输入git pull origin master,将远程仓库进行下拉,获取同步


git pull origin master


7、添加上传文件


输入git add . ,将所有文件添加


git add .


8、暂存文件


输入git commit -m “add new file”,提交代码


git commit -m “add new file”


9、提交暂存文件到指定分支


输入git push origin master,将代码上传至远程仓库的master节点


git push origin master

目录
相关文章
|
12月前
|
Shell 网络安全 开发工具
手把手教你配置Git客户端上传代码至Gitlab仓库
手把手教你配置Git客户端上传代码至Gitlab仓库
252 1
手把手教你配置Git客户端上传代码至Gitlab仓库
|
2月前
|
Linux 网络安全 开发工具
码农日常生活之Git & Gitlab & Gitk
本文是关于Git和GitLab的配置使用教程,包括基础设置、日常命令操作以及图形工具的使用。
41 2
|
2月前
|
开发工具 git
[git]记配置本地git到gitlab并推送
[git]记配置本地git到gitlab并推送
|
2月前
|
Linux 开发工具 git
[git]基于GitLab搭建本地Git服务
[git]基于GitLab搭建本地Git服务
|
4月前
|
开发工具 git
idea中git替换,推送到新的github或者gitlab上面
idea中git替换,推送到新的github或者gitlab上面
315 2
|
11月前
|
存储 Shell 开发工具
【Git】Git安装入门使用&常用命令&Gitee远程仓库上传文件与下载
【Git】Git安装入门使用&常用命令&Gitee远程仓库上传文件与下载
140 0
|
5月前
|
安全 Shell 网络安全
Git学习---Git快速入门、Git基础使用、Git进阶使用、Git服务器使用(IDEA集成GitHub、Gitee、GitLab)、GitHub Desktop客户端
Git学习---Git快速入门、Git基础使用、Git进阶使用、Git服务器使用(IDEA集成GitHub、Gitee、GitLab)、GitHub Desktop客户端
184 0
|
5月前
|
存储 Linux 网络安全
Git - Centos7下安装GitLab服务器
Git - Centos7下安装GitLab服务器
142 1
|
5月前
|
网络安全 开发工具 git
Git在windows下上传文件至github流程
Git在windows下上传文件至github流程
36 0
|
5月前
|
网络安全 开发工具 数据安全/隐私保护
Git - 记一次完整的新旧Gitlab迁移
Git - 记一次完整的新旧Gitlab迁移
384 0
下一篇
无影云桌面