2

I'd like a way to get a pager-view (less) of a buffer of git diff and git status to get a nice complete summary of the state of my working changes. It helps because git diff alone will hide the staged changes whereas status will be able to highlight that.

I know I can probably do something like

{ git status && git diff | cat }

which basically concats the output here, but this causes git diff to drop the syntax colors.

I could probably use perl but I'd like to use some neat sh, bash or zsh trick to concat this stuff while keeping colors intact.

Also, my git diff uses

[pager]
    log = diff-highlight | less
    show = diff-highlight | less
    diff = diff-highlight | less

So perhaps i gotta set something custom up where it skips the use of less so I can apply my less over the concatenated output.

4

1 に答える 1

4

すでにコミットされているものと明示的に比較するだけです:

git diff HEAD

これにより、何がステージングされているかどうかに関係なく、完全な差分が表示されます。ステージングされたものとステージングされていないものを確認したい場合は、連結する前に明示的に色を要求できます。

git status && git diff --color | cat

これでもgit statusコマンドから色が削除されることに注意してください。それも色付けしたい場合は、Git の機能を利用して、コマンドごとに構成値をオーバーライドできます。

git -c color.ui=always status && git diff --color | cat
于 2013-04-10T06:03:16.820 に答える