git使用笔记

显示某个文件在指定提交范围内的提交历史:

git log 6fb336324..7b28a4d5 src/sql/ob_item_type.h

显示某一个文件的某一次提交的修改diff内容:

git show -p 74fe861 src/sql/ob_item_type.h

git rebase -i xxx的使用注意:

rebase命令会把当前分支的提交重新应用到xxx的提交之后(从分叉点开始之后才能算当前分支的提交)
在交互编辑器中显示的信息:
xxx1
xxx2
xxx3

这些提交是按照时间顺序排列的,xxx1是早于xxx3的

git apply一个patch文件的用法

生成patch文件
git diff > all_diff.patch  #将所有不同都输出到patch文件
git diff src/some_file.c > some_file_diff.patch   #仅将某一个文件的不同输出到patch文件
应用patch文件
git apply all_diff.patch    #将all_diff.patch中所有的diff都应用到当前代码
git apply --include=src/some_file.c all_diff.patch    #仅将src/some_file.c的diff应用到当前代码
将某次commit的内容apply到当前代码
git show -p xxxx | git apply

查看当前提交下对应的tag:

git describe --always --tags #显示HEAD对应的所有tag,如果没有就会显示:{前驱提交中最近的tag名称}-{距离该tag的提交数}-g{HEAD的9位短提交号}
例如:release_v1-10-ga0a0a0a0a

查看包含某个提交的所有tag:

git tag --contains HEAD
posted @ 2023-01-03 15:47  bug批发零售  阅读(38)  评论(0)    收藏  举报