GibLab 笔记

来源:互联网 发布:淘宝网企业店铺标志 编辑:程序博客网 时间:2024/06/02 02:45

Git 使用手册 (测试工具GitLab)

1 配置 SSH

1.1 生成 SSH 密钥

检查是否已经有了 SSH 密钥,如果没有则该文件不存在,否则需要备份删除,或者直接到步骤2进行拷贝。

$ cd ~/.ssh

生成密钥

$ ssh-keygen -t rsa -C "Myron@163.com"

然后会弹出提示输入保存位置,位置如果不是 /Users/UserName/.ssh/id_rsa 则需要手动输入。密码一般设置为空。

Generating public/private rsa key pair.Enter file in which to save the key (/Users/Myron/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: 

1.2 在 Github 上添加 SSH 密钥

一般添加的是公钥,所以是 id_rsa.pub 里面的内容,可以用自己喜欢的编辑器打开这个文件复制。或者直接通过命令行将内容拷贝到黏贴板中。

$ pbcopy < ~/.ssh/id_rsa.pub

2GitLab 基本操作

2.1 新建仓库

登录 GitLab 网站 https://about.gitlab.com/gitlab-com/

输入账号密码之后点击右上角的 “+” 号选择创建 “New project”。输入对应信息后保存。

2.2 设置 Git 的 user name 和 email

命令行中输入

$ git config --global user.name "UserName"$ git config --global user.email "UserEmail"/*$ git config --global user.name "Myron"$ git config --global user.email "Myron@163.com"*/

2.3 clone 文件到本地

先 cd 到要放置文件的地方,然后输入 git clone 指令,将文件下载到本地。

$ git clone git@eserver:Myron/GitLabTest.git// eserver 是读取地址的命令,可能会无法读取,需要手动替换成地址。

2.4 添加文件修改编辑等操作……

……

2.5 添加需要上传的文件(可以是新文件,也可以是被修改的文件)

// 直接添加所有文件$ git add .// 只添加指定文件$ git add fileName

2.6 把上传的内容进行说明

$ git commit -m "说明内容。"// 如果不进行 commit ,则 master 不会存在。~~~~

2.7 创建推送

$ git remote add PushName git@eserver:Myron/GitLabTest.git// PushName 是本次推送的名称
// 显示当前推送$ git remote show$ git remote -v
// 删除指定推送$ git remote rm PushName

2.8 上传

// 查看当前分支$ git branch
$ git push PushName master:master// 第一个 master 是当前分支名称// 或$ git push -u PushName master

2.9 上传已经存在的内容

// 1. cd 到文件所在的位置// 2.$ git init// 3. $ git add .// 4.$ git commit -m "Something"// 5.$ git remote add PushName git@eserver:Myron/GitLabTest.git// 6.git push -u origin master
0 0