git bash
- 安装
- 打开bash设置用户信息
# 设置bash的用户名和email,和github的用户名,email相同
git config --global user.name "XXX"
git config --global user.email "XXX@XX.com"
#查看用户名和email
git config --global --list
- 生成ssh key
ssh-keygen -t rsa -C "your_email@youremail.com"
记得保存key的路径,打开id_rsa.pub,复制里面的key,在github网页端,进行用户的ssh key设置。这样子你的电脑和你的github就绑定在了一起。
- clone项目
git clone "项目的git"
- 同步远程仓库与本地仓库
修改过代码之后,以此进行
# 中间有空格
git add .
git commit -m "提交修改信息"
# 首次push时可以添加 -u,新建master分支,之后就不用在输入-u
git push -u origin master
其他命令可见: https://git-scm.com/docs
后来发现:http://www.runoob.com/w3cnote/git-guide.html 菜鸟教程上讲的也挺详细的
Q:如果提交代码之后,github并未显示contribution
A:要检查git config --global --list
,查看用户信息是否和github是否相同
- 在网页端设置用户信息的 public email
- 本地bash的邮箱要和public email相同。注意在设置bash用户信息的时候,不要加等号!!!user.name = "XXX"是错的!!!作者本人就是因为这个问题困扰了很久。。