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

后端 未结 4 2076
一个人的身影
一个人的身影 2021-01-31 08:09

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

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

4条回答
  •  抹茶落季
    2021-01-31 08:36

    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

提交回复
热议问题