Ubuntu安装Git及Git配置

1、检查Git是否已经安装

使用git version,若不显示版本号则Git未安装,下面是我安装好后显示的版本号
在这里插入图片描述

2、安装Git

sudo apt-get install git

Centos使用yum install -y git安装Git
稍等几分钟,下载后会自动解压安装

3、配置Git全局变量

git config --global user.name "用户名"
git config --global user.email "邮箱地址"

4、生成ssh密匙及密匙上传

ssh-keygen -C 'you email [email protected]' -t rsa

注意将you email [email protected]改为自己的邮箱地址
完成后会在用户目录~/.ssh/下建立相应的密钥文件。
使用命令cd ~/.ssh 进入~/.ssh文件夹
输入cat id_rsa.pub,复制其中内容,进入GitHub官网配置ssh密匙
在这里插入图片描述
在这里插入图片描述
Title随便填写,主要是为了自己区分,key中输入刚才复制的id_rsa.pub中的内容。

5、Git常用命令

1. 本地文件上传到github

 进入该文件夹
 git init      
 git add .
 git remote add origin [email protected]:your username/文件夹名称.git
 git commit -m "备注"
 git push origin master   //推送代码
 git pull   //拉代码

2. 从远程库克隆

git clone 仓库地址

猜你喜欢

转载自blog.csdn.net/weixin_46353366/article/details/112992341