Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
695 views
in Technique[技术] by (71.8m points)

zsh - How can I get 'git status' to always use short format?

I'd like git status to always use the short format:

$ git status --short
 M file1
 M dir/file2
?? file_untracked3
?? dir/file_untracked4

There doesn't seem to exist a configuration option for this, and git config --global alias.status "status --short" does not work. I haven't managed to create an alias in zsh either.

How can I make git status to use the short format by default?

question from:https://stackoverflow.com/questions/2927672/how-can-i-get-git-status-to-always-use-short-format

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Starting git1.8.4 (July 2013), you can configure git status to use short by default.
See commit 50e4f757f4adda096239c1ad60499cf606bf2c6f:

Some people always run 'git status -s'.
The configuration variable status.short allows to set it by default.

So:

git config status.short true

And you would be all set!


Ben Allred adds in the comments:

A quick test shows that git config status.branch true works as well, to show the branch information in conjunction with short-format.


It was reversed for a time:

Commit 908a0e6b98e5a7c4b299b3643823bdefb4fa512e:

It makes it impossible to "git commit" when status.short is set, and also "git status --porcelain" output is affected by status.branch.

But it is now back, still for git 1.8.4 (July/August 2013)

See commit f0915cbaf476d63f72c284057680809ed24fbe0d:

commit: make it work with status.short

With "status.short" set, it is now impossible to commit with status.short set, because it acts like "git commit --short", and it is impossible to differentiate between a status_format set by the command-line option parser versus that set by the config parser.

To alleviate this problem, clear status_format as soon as the config parser has finished its work.

Signed-off-by: Ramkumar Ramachandra


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...