Here is how you can do this via the commandline for one or more lines:
git log -L 40,50:app/models/user.rb
git log -L 40,50:app/models/user.rb
This page provides some other techniques: https://tekin.co.uk/2020/11/patterns-for-searching-git-revis... but I think they have their own limitations.