追踪一个函数的变更历史可以使用 I want to view the commit history for a specific function
git log -L :FunctionName:FilePath
谢谢weixin_43412244的评论,进行一下拓展,
如果想查看特定区间内函数的修改历史,请参考我在SO的问题git show modification of a function between two commits
如果想查看某个同名函数(overloading)的历史,请参考我在SO的问题git history of a function with overloading
这条指令可能对类似C
语言适用,对于其他语言git
也提供了相应的支持,需要配置一下。
参考:
generating diff text
Git - how do I view the change history of a method/function?
Is there a way to ask git diff to show the method name instead of the class name?
实例,对java的配置,
1. 添加
*.java diff=java
到 ~/.gitattributes
3. git config --global core.attributesfile "~/.gitattributes"
测试: