Ubuntu中git初次使用

一. git安装及github账号注册

1. git 安装

下载地址:
https://git-for-windows.github.io/

2.github创建账号

https://github.com/ 

二. git初始化配置

Git安装成功后,打开Git Bash

1.设置user.name和user.email

$ git config --global user.name "你的用户名"
$ git config --global user.email "你的邮箱"

2.生成SSH秘钥

当前用户目录下执行以下语句,然后查找.ssh文件夹,在/home/acer(我当前用户的用户名)/.ssh,也可以用命令find -name ".ssh"

$ ssh-keygen -t rsa -C "你的邮箱"

如果不设置密码,连续三个回车,最终.ssh文件夹下生成两个文件:

id_rsa
id_rsa.pub

3.添加秘钥

.ssh文件目录下执行

$ ssh-add id_rsa

如果报错:Could not open a connection to your authentication agent. 
则先执行:

$  ssh-agent bash

之后再执行:

$ ssh-add id_rsa

则执行结果:

Identity added: id_rsa (id_rsa)

4. 登录github,配置ssh

点击用户头像位置,选择settings

左侧选择 SSH and GPG keys

选择 New SSH key

title: 自己起个名字
key: 复制你本地.ssh文件目录下id_rsa.pub的内容

点击 Add SSH key

5.测试配置结果

ssh -T git@github.com

会看到:

The authenticity of host 'github.com (192.30.255.112)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)?

选择 yes

最终会提示:

Hi 你的用户名! You've successfully authenticated, but GitHub does not provide shell access.

至此,说明配置成功~~

 

对于删除repositories

 

进入setting后,拉到最下面

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值