I am using git on terminal on OS X 10 Yosemite.
When I do git diff I get long list of changes and sometimes I just need to scroll to the end but I couldn't figure out a way to do that other than to hold the keydown on MacBook pro and then it scrolls slowly.
if I press FN+down key then it does not scroll unless I have made the scroll down journey already down using the down button, but does not go further down...
any advice will be appreciate this is very annoying... :(
You can scroll the screen while holding fn or Shift ⇧ key. You can disable this completely by unticking: Terminal Preferences → Profiles → Keyboard → Scroll Alternate Screen.
You can press q to exit. git hist is using a pager tool so you can scroll up and down the results before returning to the console.
git diff
uses the same pager as less Unix command.
d
and u
to go down / up half pages (forward / backward technically)G
h
if you want to display the helpAnother trick is storing the diff as a patch file like they used to do in the email days! Then you can open up the patch in any program (Sublime has syntax highlight red/green)
Some examples:
git diff master > ~/patch
git show someCommitSHA > ~/patch
git diff master myBranch -- *.js *.css > ~/patch
patch of js & css diff from master
git apply ~/patch
Normally you would use the patch by applying the diff, but you can just open the file in any text editor. It's useful if you don't want to make a full commit out of your diff, but still want to use it somewhere else or send it to a friend
You can also use
git diff master | grep -C 2 someKeyword
to show diff +/- 2 lines around some keyword
git config --global core.pager "less -+\$LESS -RS"
On my new macOS laptop, that got the git log scroll working as I'd expect (page up / page down buttons working, color, wheel scroll).
Why does this work? Per the git-config manpage:
Note that git sets the LESS environment variable to FRSX if it is unset when it runs the pager.
Per the less manpage:
-X Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen.
I don't actually know what any of that means, but that X breaks page up / page down / scroll wheel.
-F Causes less to automatically exit if the entire file can be displayed on the first screen.
If you don't have X, then F breaks when there's no paging, presumably because less exits immediately and something prevents it from printing directly to the terminal.
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