gitlab搭建
安装git(免费、开源的分布式版本控制系统)
linux上查看是否安装git
>$git
Windows版的Git,从https://git-for-windows.github.io下载(网速慢的同学请移步国内镜像),然后按默认选项安装即可。
git基本配置
右键->Git Bash here
指定git的使用者
1、全局有效的,表示这条机器上所有git仓库都会使用这个配置
>git config --global user.name "your name"
>git config --global user.email "email@example.com"
2、特定项目需对特定仓库指定特定的用户名和email
2.1、使用直接修改配置文件,打开隐藏文件夹.git
>git .git
>vi config
[user]
name = xx (用户名)
email = xx (邮箱号)
按esc键
:wq!(保存退出)
2.2 、使用命令
>cd .git
>git config user.name "xxx"(有待考察)
>git config user.email"xxx"
配置SSH
1、查看是否生成ssh
>cd ~/.ssh
>ls
如果没有秘钥则不会有此文件夹,有则配备后删除(一定要重新生成)
2、生成密钥
>ssh-keygen -t rsa -C "email@example.com"
接下来三个输入意思,意思以此是 密钥的名字(有时候有多个邮箱账号时,则会存在多个公私秘钥)、密码、确认密码吗
按三个回车、表示密码为空。
> ls
最后得到了两个文件:id_rsa和id_rsa.pub
复制id_rsa.pub 的内容到 gitlab的ssh配置中
值得注意的是
1、如果告诉秘钥不正确,确定是否是删除原来的密钥,在重新生成的(删除重新安装步骤2再进行一次,反正我是遇到这个坑)
2、如果git add . 已经存在的项目,只是提交了一个@filename的话,检查原始项目中是否已经存在多个git仓库
标错提示如下
#On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # (commit or discard the untracked or modified content in submodul..
在初始化已经存在的项目文件,推荐先使用如下命令
>cd filedir
> find . -name ".git" | xargs rm -Rf 或 rm -rf .git