暂存 git stash
查看暂存 git stash list
调出暂存 git stash pop
可以查询每一行代码的 commit ID、提交者和提交日期 Git blame
经常配合 git blame,从而查询整个 patch Git show
记录了 git 某个分支的每次操作,通常用来恢复误操作影响的数据 Git reflog
取消commit git reset --soft
回退到上个版本 git reset --hard HEAD^
回退到前3次提交之前,以此类推,回退到n次提交之前 git reset --hard HEAD~3
退到/进到,指定commit的哈希码(这次提交之前或之后的提交都会回滚) git reset --hard commit_id
全部code回到2020-11-12 20:00 这个时间点前的一段code
repo forall -c 'commitID=`git log --before "2020-11-12 20:00" -1 --pretty=format:"%H"`; git reset --hard $commitID'
完成了一些功能,需要上code
- 检查代码,确保代码中没有行尾空格,确保代码对齐格式正确(使用tab对齐而不是多个空格)。
- 在vim normal模式下,输入gg=G可对齐代码。
- 在vim nromal模式下,输入:%s/\s\+$//g可去除所有行尾空格。
- git add <files>
- git commit
- 在commit message文件中填写相应字段。
- git push origin HEAD:refs/for/master
已经commit,但未push,发现有些地方需要改动,又不想有新的commit
- 修改代码
- git add <file>
- git commit --amend
已经push,发现有些地方需要改动,又不想有新的commit和Change-id
- 修改代码
- git add <file>
- git commit --amend
- 在commit message文件中添加一行:Change-Id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,Change-id可以在gerrit对应Change的页面中获得。
- git push origin HEAD:refs/for/master