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.

  • can git be used for version control on non text documents such as word doc or xls etc
  • Git Partial Fork, synced pull/merge
  • git: empty arguments in post-receive hook
  • How to know if a git submodule commit is already pushed into the repository
  • Failed to execute git command in Docker container using fig/crane
  • Capistrano and several SSH keys
  • How can I make git status to use the short format by default?

  • Bitbucket Pipelines - multiple branches with same steps
  • Should git change the ending of line? (control+M or ^M at the end of the first line)
  • GitHub: can I offer access to compiled files without versioning them?
  • git workflow with main svn repository using git-svn
  • Why is my Ruby Git script hook run with the wrong $PATH?
  • git clone timed out when used through https proxy
  • 4 Solutions collect form web for “How can I get 'git status' to always use short format?”

    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

    Use a different alias. Instead of trying to alias ‘status’, do:

    git config --global alias.s 'status --short'
    

    Now “git s” gives you short output, and “git status” gives
    you long output.

    The easiest way is to use another alias, as I suggest in my comment. I think there is no way to create an alias with the name of a built-in command. If you insist on using git status, another option is (git is open source after all):

    • get the git source code (e.g. http://github.com/git/git/)
    • open the file builtin/commit.c
    • look for the function int cmd_status(int argc, const char **argv, const char *prefix)
    • at the bottom you find a switch-statement
    • comment out the two lines as shown in the following code
    • add the line as in the following code

    code:

    ...
    switch (status_format) {
        case STATUS_FORMAT_SHORT:
            wt_shortstatus_print(&s, null_termination);
            break;
        case STATUS_FORMAT_PORCELAIN:
            wt_porcelain_print(&s, null_termination);
            break;
        case STATUS_FORMAT_LONG:
            //s.verbose = verbose;      <--lines have to be commented out
            //wt_status_print(&s);
            wt_shortstatus_print(&s, null_termination);    //<-- line has to be added
            break;
        } 
     ...
    
    • remake git

    You may create an alias.

    But I’d create bash script:

    #!/bin/bash
    git status --short
    

    save this script in ~/bin/gits (or /usr/bin/gits and chmod 555), so typing gits gives what you want.

    Git Baby is a git and github fan, let's start git clone.