http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html
重复commit
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
解决:
git reset --hard origin/master
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
ssh-keygen -t rsa -C "youremail@example.com" id_rsa.pub为公钥
git status
git add .
git commit -s -a -m "message"
git review -R -v
git init
git push
git pull
git clone
追加
git commit --amend
版本回滚
git reset --hard 8d722bb
撤销工作区修改(未add):
git checkout -- 文件名
撤销对某文件的add(已add未commit,缓存区->工作区):
git reset HEAD 文件名
日志:
git log --pretty=oneline --abbrev-commit
--abbrev-commit:短id
查看历史命令:
git reflog
查看分支合并图
git log --graph
分支:
创建:
git branch 分支名
查看:
git branch -l
删除:
git branch -d 分支名
强行删除未合并分支:
git branch -D 分支名
切换:
git checkout 分支名
创建并切换
git checkout -b 分支名
合并分支到当前分支(conflicts冲突后手动解决冲突再 add commit);
git merge 分支名
分支图会显示分支:
git merge --no-ff -m "合并信息" 分支名
git log --pretty=oneline --abbrev-commit --graph
保存现场;
git stash
恢复现场:
git stash pop
message:
feat:新功能(feature)
fix:修补bug
docs:文档(documentation)
style: 格式(不影响代码运行的变动)
refactor:重构(即不是新增功能,也不是修改bug的代码变动)
test:增加测试
chore:构建过程或辅助工具的变动
git commit --amend
切换远程分支并提交分支:
git clone ***
git branch release_1.1.2 remotes/origin/release_1.1.2
git checkout release_1.1.2
git review -R -v release_1.1.2