常用git和gerrit

工作

Posted by zhangzexin on April 29, 2021

gerrit流程

流程图

常用git命令

git commit --amend -m "message"   添加合并commit
git commit -a   全部提交
git commit -v   显示diff并提交
git commit -m "message"   标准commit
git commit [file] -m "message"   分文件commit
git reset HEAD~1   回退commit

git pull --rebase   
git push origin HEAD:refs/for/master   推到pending changes
git push origin --delete [branch]   删除远程分支

git status
git log --stat   commit历史
git log -S [keyword]   搜索提交历史
git log   版本历史
git diff  远程与本地区别
git diff HEAD   当前工作区与最新commit区别

git stash   暂存修改
git unstash   恢复修改
git init []/[project-name]   新建
git clone [url]   克隆
git rm [file]   删除
git add [file]/[dir]/.   添加文件到git
git mv [file-origin] [file-renamed]   改名

git branch   列出本地分支
git branch -r   列出远程分支
git branch [branch-name]   停留在xx分支
git branch -dr [remote branch]   删除远程分支
git checkout -b [branch]   切换到新分支

commit message 规范

<type> |> (<scope>):<subject>

type规范

feat: 新功能(feature)
fix: 修复
	to: 多次to,最后fix
docs: 文档(documentation)
style: 样式
refactor: 重构
perf: 性能优化
test: 增加测试
chore: 构建过程和辅助工具变更
revert: 回滚
merge: 合并
sync: 同步主线或分支的bug

git组合

从远程origin/master下载最新版到本地,与本地分析差别,最后合并

git fetch 
git diff
git merge

下载,直接merge

git pull origin master

merge和rebase的区别