git基本使用

git下载

下载地址:https://git-scm.com/downloads

git基本使用

使用https

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
说明文件
echo "xxx">>README.md

初始化git仓库
git init

将项目的所有文件添加到仓库中
git add *
git add .

添加README.md文件
git add README.md

添加说明
git commit -m "first commit"

将本地的仓库关联到GitHub
git remote add origin https://github.com/xxx/xxxx.git

取消本地的仓库关联到GitHub
git remote rm origin

上传到github
git push origin master

输入useranme和password

查看当前git仓库状态
git status

使用ssh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
需要配置ssh key
ssh-keygen -t rsa -C "注册github的邮箱"

需要输入密码可以不输
随后在github网站添加shh key

验证是否成功
ssh -T git@github.com

设置username
git config --global user.name "name"

设置email
git config --global user.email "email"

将本地的仓库关联到GitHub
git remote add origin git@github.com:yourname/yourrepo.git
后面和https一样

相关链接:
https://blog.csdn.net/halaoda/article/details/78661334