开发者

How to trim commit comments in "git branch -avv"

开发者 https://www.devze.com 2023-02-09 23:02 出处:网络
I wrote a bash function which do some handy tasks on entering a git repository on console. It also gives me an overview of all branches using git branch -avv

I wrote a bash function which do some handy tasks on entering a git repository on console. It also gives me an overview of all branches using git branch -avv

For my inconvenience, git is "flooding" me when开发者_运维知识库 writing the full changelog comments which often doesn't fit the console line width

Trimming these with pipes like cut -c-$(tput cols); will remove coloring if enabled in git config ;(

The Answer: is there a way to configure git in a native way, to just output the first XX chars of the commit message? My goal is to archive this without need of further command line tools I don't know collogues have had installed them.


edit: Thanks to answer #2 (Max Nanasy): use of --color option will force coloring


What about

 git log --oneline | cut -b 1-20

May be better (without the SHA):

git log --pretty=format:'%s' | cut -b 1-20


git branch --color -avv | cut -c-$(tput cols)

0

精彩评论

暂无评论...
验证码 换一张
取 消