安装Git
因为GitLab和GitHub一样,都是一个基于Git的社区,所以我们需要安装Git
下载地址:https://git-scm.com/
安装流程图:
1.下载完之后,双击安装

2.选择安装目录

3.选择组件

4.开始菜单目录名设置

5.选择使用命令行环境

6.以下三步默认,直接点击下一步



7.安装完成

8.检验是否安装成功

配置Git
在任意盘里创建一个存放本地仓库的文件夹,比如本地仓库建在D:\Git使用方法文件下,进入git文件夹鼠标右击并点击Git Bush Here
1、Git安装之后需要进行一些基本信息设置
a、设置用户名:git config -- global user.name '你再github上注册的用户名';
b、设置用户邮箱:git config -- global user.email '注册时候的邮箱';
注意:该配置会在github主页上显示谁提交了该文件
c、配置ok之后,我们用如下命令来看看是否配置成功
git config --list
注意:git config --global 参数,有了这个参数表示你这台机器上所有的git仓库都会使用这个配置,当然你也可以对某个仓库指定不同的用户名和邮箱
2、初始化一个新的git仓库
a、创建文件夹
方法一:可以鼠标右击-》点击新建文件夹test1
方法二:使用git新建:$ mkdir test1

b、在文件内初始化git(创建git仓库)
方法一:直接输入 $ cd test1
方法二:点击test1文件下进去之后-》鼠标右击选择Git Bash Here->输入$ git int

3、向仓库中添加文件
方法一:用打开编辑器新建index.html文件
方法二:使用git命令。$ touch '文件名',然后把文件通过$ git add '文件名'添加到暂存区,最后提交操作


4、修改仓库文件
方法一:用编辑器打开index.html进行修改
方法二:使用git命令。$ vi '文件名',然后在中间写内容,最后提交操作

5、删除仓库文件
方法一:在编辑器中直接把要删除的文件删除掉
方法二:使用git删除:$ git rm '文件名',然后提交操作

6、GitLab创建项目
注册并登录
为项目添加SSH Keys
点击右上角“头像”——“setting”——“SSH Keys”

在Git Bush窗口内输入以下命令生成ssh key
ssh-keygen -t rsa -C "你自己的邮箱地址"

在C:\Users\Administrator\.ssh 文件内有id_rsa.pub,使用编辑器打开复制黏贴至上图Key内。
网友评论