2

When I git diff 2 identical branches, or even the same branch, I get the following output:

lines ?-?/? (END)

I'm not sure what the significance of this message is, or how to resolve it. I've been ignoring it thus far, but I'd prefer it not appear. What is causing this and how do I address it?

2
  • This looks like something displayed by a pager, having reached the end of zero lines of output it is telling you that it is now displaying lines ? through ? out of ? lines (i.e., all three are unknown) and that you are at the end of the display. What do you have your pager set to?
    – torek
    Apr 20, 2014 at 22:46
  • I'm not sure what the pager is... I'm running git diff out of the Gnome terminal on OpenSuSe, if that helps.
    – Kvass
    Apr 20, 2014 at 23:53

1 Answer 1

0

git diff uses less as its pager by default. Typically, less will always stay open until you press q. If there is nothing for less to display, it defaults to the output you are seeing until it quits.

From the less man page:

-F or --quit-if-one-screen

Causes less to automatically exit if the entire file can be displayed on the first screen.

Adding -F to the command line options for less will make git diff just return the shell prompt if there are no changes to display. There are a couple ways to do this:

  1. Add -F to the the LESS environment variable

    • You can modify your ~/.bashrc or ~/.bash_profile if using bash by adding export LESS="-F", or adding -F to the argument list if this line already exists.
    • You can create a less.sh file and place it in /etc/profile.d/ with the same thing (`export LESS="-F")
  2. You can alias the less the command to add the options:

    • Add alias less='less -F' to your ~/.bashrc or ~/.bash_profile
    • This method may or may not work directly with git diff (untested)

Not completely relevant but still related: If you are going to add -F to your LESS options, I'd also recommend adding -R -X -I. You can read about them in the less man page, but suffice to say they make less a little more awesome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.