gitlab使用

初次Windows使用gitlab出现了诸多多问题但已解决,在这里记录一下。

首先就是要安装gitlab以及TortoiseGit

然后就是ssh秘钥匹配了,首先生成秘钥:

1.随意右键

gitlab使用

2. 输入

ssh-****** -t rsa -C "yourmail@gmail.com"

3. 生成单个SSH Key时可以连续回车,不输入**文件名字和密码,生成后会在【C:\Users\用户名.ssh】下产生两个文件,如图:

gitlab使用

4.打开复制里面的秘钥,然后去gitlab

gitlab使用

5. 然后配置全局的name和email,参照你创建的工程Git global setup,输入

        git config --global user.name "hszzjs"
        git config --global user.email "[email protected]"

6.输入

        ssh -T [email protected]

 出现hello hszzjs就是成功了!

7. 接下来就是项目上传了,下载很简单,随便一搜就有

首先在gitlab上创建你要生成的工程,必须是新工程

gitlab使用

8.然后就是到你要上传的文件夹

gitlab使用

输入:

git config --global user.name "hszzjs"
git config --global user.email "[email protected]"
git init
git remote add origin ssh://[email protected]/test.git
git add .
git commit -m "程序源代码"

git push -u origin master

这里注意,如果 git remote add origin ssh://[email protected]/test.git 输入后报错显示 fatal: remote origin already exists.,需要输入如下:

gitlab使用

然后就是上传成功啦!

=========================updating-2018.6.23===================

今天继续试用gitlab上传,结果出现报错:

$ git push -u origin master
error: src refspec master does not match any.

error: failed to push some refs to '[email protected]:lab/References.git'

如图:

gitlab使用

经过查找资料发现是基于:目录中没有文件,空目录是不能提交上去的

然后使用如下代码解决:

touch README
git add README 
git commit -m 'first commit'
git push origin master

然后就成功解决了

=================================再次更新===============================

是这样之前忘了说明,事实上这里我使用的是TortoiseGit,以下都是基于它进行的,这次主要是讲如何来实现实时更新,对于创建的工程如何进行实时更新:

事实上使用TortoiseGit能够很方便的上传项目,更新等,而且也不需要通过命令行来进行操作。

安装教程如下:https://blog.whsir.com/post-1801.html

具体使用如下:https://blog.****.net/zcmain/article/details/76544636