使用gitlab
(1)删除已有的公钥
(2)使用Git bash创建RSA 公私玥
使用命令:ssh-keygen.exe
私钥默认路径:/c/Users/admin/.ssh/id_rsa
执行结果:
$ ssh-keygen.exe
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/admin/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/admin/.ssh/id_rsa.
Your public key has been saved in /c/Users/admin/.ssh/id_rsa.pub.
The key fingerprint is:
31:87:7e:23:33:8f:70:61:c9:29:66:a4:7e:2c:db:98 admin@ADMIN-PC
The key's randomart image is:
+--[ RSA 2048]----+
| . |
| o . + |
| . + X . |
| . + + = |
| o + S o |
| B o B . |
| E . . . |
| |
| |
+-----------------+
生成的公私玥:
其中,id_rsa.pub 是公钥,需要拷贝id_rsa.pub内容到github中
把上述内容拷贝到github中,如下图
注意:内容后面不能有空格和换行.
添加成功:
这样就可以使用git bash直接clone 代码库勒.
使用命令:git clone git@gitlab.rd.chanjet.com:aaa/bb_web.git
查看分支:
git branch -r
检出指定分支
git checkout origin/dev_revert_online
提交修改的文件(commit)
第一次提交时失败
解决方法:
先执行:git config --global user.email "huangwei@chanjet.com"
然后就提交成功了
查看最后一个commit了的文件
git log -n 1
提交流程
git add index.html
git commit -m "test" *
git push
$ git checkout
Your branch is up-to-date with 'origin/master-bug'.