Git和GitHub的关联

本文介绍如何配置Git的基本信息如用户名、邮箱等,并设置文本编辑器和差异分析工具。此外,还详细说明了如何生成SSH密钥及在GitHub上进行配置,以实现安全的远程仓库操作。

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

Git的配置:

$ git config --global user.name "Firstname Lastname"
$ git config --global user.email yourEmailAdress
$ git config --global core.editor vim
$ git config --global merge.tool vimdiff

这个命令会在~/.gitconfig中创建你的个人信息

  • 名字

  • 电子邮件

  • 文本编辑器

  • 差异分析工具

$ git config --list

**这个命令可以显示你当前的信息**

user.name=Tom Black
user.email=iamtomblack@outlook.com
core.editor=vim
merge.tool=vimdiff

设置SSH Key

$ ssh-keygen -t rsa -C "your_email@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key
(/Users/your_user_directory/.ssh/id_rsa): 按回车键
Enter passphrase (empty for no passphrase): 输入密码
Enter same passphrase again: 再次输入密码

出现如下结果

Your identification has been saved in /Users/your_user_directory/.ssh/id_rsa.
Your public key has been saved in /Users/your_user_directory/.ssh/id_rsa.pub.
The key fingerprint is:
fingerprint值 your_email@example.com
The key's randomart image is:
+--[ RSA 2048]----+
|     .+   +      |
|       = o O .   |
 略

进入GitHub官网假定你已经注册settings->SSH and GPG keys->New SSH key

你需要填写一个任意有意义的Title

key:

$ cat ~/.ssh/id_rsa.pub
ssh-rsa 公开密钥的内容 your_email@example.com

测试

$ ssh -T git@github.com
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is fingerprint值 .
Are you sure you want to continue connecting (yes/no)? 输入yes

成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值