赞
踩
git log 是 Git 中用于查看提交历史的命令。以下是一些常用的选项和用法:
git log # 显示提交历史
git log -p -2 # 显示最近两次提交的内容差异
git log -n <limit> # -n限制显示的日志条目数量,<limit> 是你想要查看的最近的提交数。
git log --oneline # 以单行显示提交历史
git log --graph
# git log --since=<date>:查看指定日期后的提交
git log --since="2 weeks" # 显示最近两周的提交
# git log --author=<author>``:查看指定作者的提交
git log --author="John" # 显示John的提交
示例:
# git log --grep=<pattern>`:搜索提交信息中匹配指定模式的提交
git log --grep="bug fix" # 搜索包含'bug fix'的提交信息
git log -S"function name" # 搜索包含'function name'修改的提交
git log -- <file-path> # 查看指定文件的提交历史
# git log -S<keyword>:搜索提交中添加或删除了包含指定关键字的行的提交
git log -S"function name" # 搜索包含'function name'修改的提交
查看指定文件的提交历史——git log -p命令用于显示提交历史以及每次提交所引入的差异(即patch)。-p选项是一个简写,它实际上是–patch的简写。
git log -p
git log -p -N
其中,-N是一个数字,表示显示最近的N次提交。
git log -p -- 文件名
git log -p --author="作者名"
git log -p --since="1 week ago" --until="yesterday"
git log --stat
git log --oneline
以列表方式查看指定文件的提交历史——git blame是一个非常有用的Git命令,用于追踪文件中每一行代码的最后修改者和时间。这个命令可以展示一个清晰的历史记录,显示每行代码是谁在何时添加的。
git blame <file>
这将为指定的文件提供每行代码的修改历史。
git blame -e <file>
git blame -l <file>
git blame -s <file>
git blame -C <n> <file>
git blame <commit_hash>^..<file>
这里的<commit_hash>是你想要开始追踪的版本的哈希值。
git blame <file> > blame.txt
这将会把git blame的输出保存到blame.txt文件中。
关于《Git常用命令》详细讲解这篇文章,老吕也没想到,随手写啊写啊,Git命令详细的写一写还真的写了好多内容,直接发布后,发现手机看这文章的时候,居然卡屏了,所以无奈只能把这篇文章的内容分拆成10篇发布出来,以下是全文各篇章的链接:
1. 《Git常用命令》详细讲解·第1篇(git clone和git init)
https://pythonlaolv.blog.csdn.net/article/details/137091558
2. 《Git常用命令》详细讲解·第2篇(git status和git diff)
https://pythonlaolv.blog.csdn.net/article/details/137095087
3. 《Git常用命令》详细讲解·第3篇(git add、git mv和git rm)
https://pythonlaolv.blog.csdn.net/article/details/137095175
4. 《Git常用命令》详细讲解·第4篇(git commit -m “commit message“和git commit --amend)
https://pythonlaolv.blog.csdn.net/article/details/137095289
5. 《Git常用命令》详细讲解·第5篇(git log和git blame)
https://pythonlaolv.blog.csdn.net/article/details/137095352
6. 《Git常用命令》详细讲解·第6篇(git reset --hard HEAD、git checkout HEAD和git revert <commit>)
https://pythonlaolv.blog.csdn.net/article/details/137095501
7. 《Git常用命令》详细讲解·第7篇(git branch、git checkout <branch/tag>和git tag)
https://pythonlaolv.blog.csdn.net/article/details/137095635
8. 《Git常用命令》详细讲解·第8篇(git merge和git rebase)
https://pythonlaolv.blog.csdn.net/article/details/137095700
9. 《Git常用命令》详细讲解·第9篇(git remote -v、git remote show和git remote add)
https://pythonlaolv.blog.csdn.net/article/details/137095791
10. 《Git常用命令》详细讲解·第10篇(git fetch、git pull和git push)
https://pythonlaolv.blog.csdn.net/article/details/137111309
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。