创建版本库
添加远程库
1
| $ git remote add origin https://github.com/JohnNashs/learngit.git
|
克隆指定分支
1
| git clone -b <name> 仓库地址
|
Git 状态
三种状态
- Working Directory 工作区
- Staging Area 暂存区
- Repository 版本库
精简命令
提交代码
1 2 3 4 5 6 7 8
| git add .
git commit -m "这里是注释"
git push origin <name>
|
拉取代码
分支操作
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
| git branch
git branch NewBranchName
git chekcout NewBranchName
git checkout -b <name>
git push --set-upstream origin <name>
git checkout -b 本地分支名 origin/远程分支名
git checkout master git merge NewBranchName
git branch -d NewBranchName
|
查看 log
版本回退
1 2 3 4 5
| git reset --hard HEAD^
git reset --hard HEAD~版本号
|
重置本地账户密码
1
| git config --system --unset credential.helper
|
保存账号密码
1
| git config --global credential.helper store
|
删除本地缓存(项目提交后再建 gitignore 不生效解决方法)
升级 Git 后,仓库无法 push
1
| error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR
|
解决方式
1 2 3
| git config --global http.version HTTP/1.1 git push git config --global http.version HTTP/2
|
原则
协同开发应建立自己的分支,再合并到 master 上
博客发布指令
hexo clean && hexo g && hexo d
教程
Git 官网
廖雪峰