git常见用法

本文介绍如何在GitLab上配置SSH公钥,包括删除已有公钥、使用gitbash创建RSA公私钥对、将公钥添加到GitLab以及基本的git命令操作等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用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'.

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值