0

When I use 'git log', and then type 'q', I still see the logs on my screen as like it was printed to the screen.

I want to do it like in vim, when I open a file in vim and then close it I don't see file content, I see only the vim command. How to let git log not showing the log after exiting? (like in less command)

Atheel Massalha
  • 424
  • 1
  • 6
  • 18

1 Answers1

0

Use less utility, it would look like:

$ git log | less
Nabuchodonozor
  • 704
  • 1
  • 6
  • 13
  • @AtheelMassalha to make it permanent you can use shell alias `alias git-log-no-rubbish='git log | less'`, and put it into ~/.bashrc file – Nabuchodonozor May 04 '20 at 12:24
  • 1
    @AtheelMassalha it's only alias to 'git log | less'. Check this : https://linuxize.com/post/how-to-create-bash-aliases/ . After that you can type in shell `git-log-no-rubbish` and it will do the same as `git log | less` – Nabuchodonozor May 04 '20 at 12:37
  • nice, now I see it works I will mark this as correct answer but I bielve there is a way to get the same with "git log" and not with another aliased name thanks for the help! – Atheel Massalha May 04 '20 at 12:46
  • 1
    More likely, you just need to do `PAGER=less`. What is happening is that `git-log` is piping its output through `PAGER` and you are just explicitly overriding that behavior by piping explicitly to `less`. Also note that all of these will fail (ie, work properly) if you have included `X` in `LESS`. – William Pursell May 04 '20 at 13:08
  • @WilliamPursell PAGER=less didn't change git log behave, should I do it with another commands? and what do you mean by including X in less? – Atheel Massalha May 04 '20 at 13:39
  • 2
    You need `export PAGER=less` (also, check that GIT_PAGER is empty). If you also have `export LESS=X`, then `less` will run as if `-X` was passed on the command line, giving you the behavior you are trying to avoid. – William Pursell May 04 '20 at 17:14
  • thanks, those helped me: export LESS=R git config --global --add core.pager "less -F" but its only working for git diff/log, if I do 'git show HEAD' it still prints to the screen. is there any global fix for all git commands? – Atheel Massalha May 05 '20 at 06:04