git 多用户配置 mac

  1. 首先需要生成ssh key

参考:https://git-scm.com/book/zh/v2/%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84-Git-%E7%94%9F%E6%88%90-SSH-%E5%85%AC%E9%92%A5

691@dianzilajishoujiqi .ssh % ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/691/.ssh/id_rsa): /Users/691/.ssh/private_id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/691/.ssh/private_id_rsa
Your public key has been saved in /Users/691/.ssh/private_id_rsa.pub
The key fingerprint is:
SHA256:0mRoRBmjlhRtpp/T7lOGkx6MHEgUmqYv+wC4ZJdZcWM [email protected]
The key's randomart image is:
+---[RSA 3072]----+
|   .=*=E         |
|   +.+Oo.        |
|  +.+*o o        |
|.o .*..+         |
|+o + o.*So       |
|+o.   *.B o      |
|+ .    + =       |
| +      +        |
|...    ...       |
+----[SHA256]-----+

区别就是如果之前生成过id_rsa文件,这次需要修改一下文件名,然后一路next即可。

  1. 如果之前有生成过ssh key,此时.ssh里面就会有如下文件
691@dianzilajishoujiqi .ssh % ls
authorized_keys		id_rsa			known_hosts		private_id_rsa
config			id_rsa.pub		known_hosts.old		private_id_rsa.pub
  1. 去对应的代码库添加ssh key
    头像 -> settings -> SSH and GPG keys
  2. 本地添加私钥
ssh-add ~/.ssh/private_id_rsa

参考:https://blog.csdn.net/csdjia11/article/details/128274819?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0-128274819-blog-131900183.235v39pc_relevant_default_base&spm=1001.2101.3001.4242.1&utm_relevant_index=3
https://blog.csdn.net/tuhuanxiong/article/details/131421190?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0-131421190-blog-115871498.235v39pc_relevant_default_base&spm=1001.2101.3001.4242.1&utm_relevant_index=3

然后就可以将本地代码提交到git中了
https://zhuanlan.zhihu.com/p/136355306#:~:text=%E4%B8%8A%E4%BC%A0%E6%9C%AC%E5%9C%B0%E6%96%87%E4%BB%B6%EF%BC%88%E5%A4%B9%EF%BC%89%E5%88%B0GitHub%E5%92%8C%E6%9B%B4%E6%96%B0%E4%BB%93%E5%BA%93%E6%96%87%E4%BB%B6%201%201.%20%E4%BD%BF%E7%94%A8git%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6%E5%88%B0github%202%202.%20%E5%9C%A8github%E4%B8%8A%E5%88%9B%E5%BB%BA%E4%BB%93%E5%BA%93,3%203.%20%E8%AE%BE%E7%BD%AESSH%20key%204%204.%20%E6%9C%AC%E5%9C%B0%E4%B8%8A%E4%BC%A0%E8%87%B3github

你可能感兴趣的:(git,macos,ssh)