一、添加sshkey
1、生成sshkey
ssh-keygen -t rsa -C "$your_email"
cat ~/.ssh/id_rsa.pub
2、保存sshkey到gitlab
Profile Settings –> SSH Keys –> Add SSH Keys
把上一步中的id_rsa.pub中的内容拷贝出来粘贴到输入框中,保存
二、初始上传代码
1、进入工程目录
cd $project_root
2、初始化git仓库
git init
3、添加文件到仓库
git add .
4、设置 git global
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
5、提交代码到仓库
git commit -m 'init commit'
6、链接到git server
git remote add origin git@example.com:namespace/projectname.git
7、push代码到服务器
git push origin master
三、克隆代码到本地
git clone git@example.com:namespace/projectname.git