0
点赞
收藏
分享

微信扫一扫

git命令使用github

12a597c01003 2022-04-24 阅读 166
gitgithub

github相关设置

ssh设置

1.创建密钥
ssh-keygen -t ed25519 -C "git@github.com"

Enter file in which to save the key (/xxxx/xxx/.ssh/id_ed25519): 			# 回车
Enter passphrase (empty for no passphrase): 			# 回车
Enter same passphrase again: 		# 回车

2.后台启动ssh
eval "$(ssh-agent -s)"

3.创建和写入config
touch ~/.ssh/config
vim ~/.ssh/config

写入内容:
Host *
  IgnoreUnknown AddKeysToAgent,UseKeychain
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

4.ssh身份添加
ssh-add -K ~/.ssh/id_ed25519

5.复制密钥,在github的settings中添加密钥(title随便写)
vim ~/.ssh/id_ed25519.pub 

6.测试是否连接上github
ssh -T git@github.com

如果显示
Hi your_user_name! You've successfully authenticated, but GitHub does not provide shell access.
就表示成功了
else:
git@github.com: Permission denied (publickey).		就失败了

token设置

在项目中,用git push -u origin main上传项目需要输入github账号和token(不是密码!!!)

所以,需要设置token

Settings -> Developer settings -> Personal access tokens

创建token,全选权限就行了,一般设置个30天就差不多了

github下载code

git clone ssh地址			# 就可以下载到本地目录下
举报

相关推荐

0 条评论