git日常使用和ssh的密钥修改

1、查看代码状态

git status

2、添加修改的文件

git add .

3、提交添加的文件

git commit -m "注释"

4、提交到git仓库

git push

5、合并

git merge branch_name

6、更新

git pull

如果在第一次创建ssh的密钥匙设置了密钥,之后忘记了或者嫌每次输入密钥太烦,那么重置密钥的方法在此:
Mac下
1、查看本地ssh keys文件是否存在,可以看到id_rsa和id_rsa.pub就是之前创建的密钥对。

$ ls -al ~/.ssh
total 24
drwx------   5 {user}  staff   160  2 27 15:18 .
drwxr-xr-x+ 27 {user}  staff   864  3 18 11:30 ..
-rw-------   1 {user}  staff  3243  3 18 17:06 id_rsa
-rw-r--r--@  1 {user}  staff   748  3 18 17:06 id_rsa.pub
-rw-r--r--   1 {user}  staff   196  2 27 15:18 known_hosts

或者

$ cd ~/.ssh
$ ls -al
total 24
drwx------   5 c{user}  staff   160  2 27 15:18 .
drwxr-xr-x+ 27 {user}  staff   864  3 18 11:30 ..
-rw-------   1 {user}  staff  3243  3 18 17:06 id_rsa
-rw-r--r--@  1 {user}  staff   748  3 18 17:06 id_rsa.pub
-rw-r--r--   1 {user}  staff   196  2 27 15:18 known_hosts

2、重新创建ssh keys,主要执行第一行命令,输入邮箱,Overwrite输入y,下面一顿回车完事儿,这时候就生成了新的ssh keys。

$ ssh-keygen -t rsa -b 4096 -C "{your email}"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/{user}/.ssh/id_rsa):     
/Users/chen.yingjie/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/{user}/.ssh/id_rsa.
Your public key has been saved in /Users/{user}/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:NnhL9fyyyjVjZXDMBpg3vVlxWEx50EnJ03fZNE {your email}
The key's randomart image is:
+---[RSA 4096]----+
|           o..+##|
|          ...o=B=|
|       . . o ++ o|
|       + o   +   |
|        .   * .  |
|         . o =   |
|          o..    |
+----[SHA256]-----+

3、到gitLab设置新密钥:

$ cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDBrosq5Th4A8x+rjX5hVJjR9oJyf0VyH+Rx1lA3LFeZ5iq7T3Q994rNJdMKqed4N4xL6KhE9HwSqekMh5D132geyDjsr4DWYzsen0OVvJDir7nqJdKTKhAUW04zTmeyRYl0nqWC3R4OBLuG1MNXr3mQ1ns9JIyluzm6eL4YUMkakEL02KhVDTCs+p45Y1t6ETL7jL6/+/FYa9jyPiqxZGo2aESbFBUIB8TFpKt5kZfH7/h7k2GCBiFpqMliNMYduvHoJqIRAVQTclSXE0jxh3JDjzSf8xEryNpcs/aXXTHxsnUuR6C1AxcuFy2ZO0I5XdM2ve1Zx/kkAcHX16phFmJrUX/5lIjXSRpvsRZ1PN7K3mhCjWyoQ== {your email}

打开gitLab
在这里插入图片描述
把上面邮箱前的一堆复制到框中,title自定义,原来的可以删除(右下角)。
新密钥设置完毕。

猜你喜欢

转载自blog.csdn.net/chenyingjie_Android/article/details/88644668