How to configure git-diff so that long line not wrap around?
On an EC2 instance, I
git diff doesn’t wrap the content to the next line, generating following output (I can use left/right keys to navigate), which I personally prefer.
Does any one know how I can config the
git-diff to change from one behavior to another?
2 Solutions collect form web for “How to configure git-diff so that long line not wrap around?”
It’s your terminal or pager program that wraps the lines, not
git diff. Try redirecting the output of
git diff into a file and open it with an editor that allows to control wrapping – you will see that the lines are not actually wrapped.
You can try this:
git diff|cut -c -$COLUMNS
Note however that it will disable colors and paging.
Thank to torek’s inline response above. Based on that, I realized I can do
git diff | less -S to achieve what I want. It does better than the
cut -c -$COLUMNS solution because it doesn’t lose any context (I can still use left and right button to view all differences).