In my workflow, I often run the following pair of commands:
$ git status
M README.txt
M some/long/file/name
$ git diff some/long/file/name
Is there any way, for fast typing/use_shortcat for long file name without copying it name (this action require using mouse and it's no so fast like typing)?
Maybe something like git diff $2
, where $2
is second changed file from the status list...?
windows-10-git.mdGo to Computer Configuration > Administrative Templates > System > Filesystem in gpedit. msc , open Enable Win32 long paths and set it to Enabled .
You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch.
^M represents carriage return. This diff means something removed a Unicode BOM from the beginning of the line and added a CR at the end.
Another way you can do it without installing a separate tool is to strip the output of git status, and pipe it through sed, then back to git diff. Its a long command, so you can put it in your .bashrc and alias it. For example, putting this in my .bashrc:
myfunction() {
git status --porcelain | sed -n "${1} s/^...//p' | xargs git diff
}
alias gd=myfunction
I can then do
>> git status
M main.cpp
M tipsy.cpp
M other.cpp
>> gd 2
And the output is git diff of the second file.
EDIT: I combined the two seds into one, because having two seperate ones was silly.
You can also use *
placeholders as suggested in this answer.
Usually you don't have to type the full name of the file like this
git diff -- **/name
Given that a short segment of the name, e.g. "na", is unique within the list of modified files, you can also do something like this:
git diff -- *na*
This way you don't have to count the entries to find out which number it is that you want to diff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With