git --version #查看版本

生成密钥

ssh-keygen -t rsa -f ~/.ssh/id_rsa_github -C "[email protected]"

#生成文件
ls ~/.ssh/
id_rsa_github		id_rsa_github.pub	known_hosts

添加公钥到github

id_rsa_github.pub内容复制到github上

#测试
ssh -i ~/.ssh/id_rsa_github  -T git@github
.com

ssh -T [email protected] #会报错,需要配置config

新建config

Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_github

测试

ssh -T [email protected]

单独到项目文件夹设置用户名邮箱


git config user.email “[email protected]”
git config user.name “username”

常用命令

git add .
git commit -m "message"
git push

git status
git diff
git config --local --list

回滚

git revert ID

gitignore

https://github.com/github/gitignore

参考 https://www.cnblogs.com/kevingrace/p/5690241.html