Reputation: 1301
Is there a way to specify a partial file name in order to save keystrokes?
Instead of:
git diff path/path/path/path/path/somefilename.js
To something like:
git diff *somefilename.js
Or:
git diff .somefilename.js
Upvotes: 1
Views: 522
Reputation: 1248
Not git-based, but I often use something like
<command> $(git ls-files | grep 'somefilename.js')
to specify a file with a basename that is unique in the repository. In this case, that would be git diff $(git ls-files | grep 'somefilename.js'
.
git ls-files
will list all the files tracked in your repo. You can then grep for the basename to get the full name of the file. By doing that in a subshell ($(...)
) you can interpolate that full name into whatever command you want.
Upvotes: 1