Git: remove leading plus/minus from lines in diff

后端 未结 4 1801
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 13:26

My question is rather simple, though I have had no luck finding an answer.

I\'d like to remove the leading plus/minus symbols from each line in git diff

4条回答
  •  太阳男子
    2020-12-23 13:55

    One option is to use sed to remove the undesired character from diff, while preserving the color:

    git diff --color | sed -r "s/^([^-+ ]*)[-+ ]/\\1/" | less -r
    

    (Note that you need to remove the leading space as well, as it is emitted by diff.)

提交回复
热议问题