0

A collaborator has added a very long one-line commit message to our shared repository. I've tried viewing it using git log and git show <hash>, but in both cases the message runs off the edge of my screen.

How can I view his whole message using git from the bash command line?

astay13
  • 6,857
  • 10
  • 41
  • 56
  • Possible duplicate of [How to wrap git commit comments?](https://stackoverflow.com/questions/2119942/how-to-wrap-git-commit-comments) – phd Jan 05 '18 at 00:02

3 Answers3

1

You can use the fold command:

git log | fold -w 80 -s

According to this post, you may need to replace -w with -c.

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
1

Both git log and git show use your configured pager, by default. It's your pager, not Git, that is doing the off-edge-of-screen management.

You can:

  • temporarily change your pager: git -c core.pager=cat show ..., for instance;
  • temporarily disable your pager: git --no-pager show ..., for instance;
  • pipe the output, which by default disables pagers (but you can configure the system to always use the pager, which defeats this defeat method): git show ... | cat, for instance.

Besides these, you can use a --pretty=format:... or --format= directive to git log to specify how the commits are to be shown. Using:

git log -1 --format=%s <hash>

will show that one commit (using the pager, unless you've disabled it) using a format that shows only the subject line.

torek
  • 448,244
  • 59
  • 642
  • 775
0

If your pager is less, and it is set up to chop long lines by default (*), you can change behavior of currently running less by pressing '-', 'S'.

*) see https://git-scm.com/docs/git-config#git-config-corepager for how default is set.

max630
  • 8,762
  • 3
  • 30
  • 55