Command
git log -L :<funcname>
Example
git log -L :self.published:app/models/post.rb
Troubleshooting
In case the language of your project is not supported, then add support by making these two changes:
- Add the following lines (adjust as per your language) to
.gitattributesfile:
*.rb diff=ruby
*.swift diff=swift
- Then, define the diff pattern in
.gitconfig(or.git/config). Example:
[diff "swift"]
xfuncname = ^[ \t]*((class|struct|func)[ \t].*)$
You can also define the gitattributes globally using:
git config --global core.attributesfile ~/.gitattributes