temp
temp

Reputation: 195

git status print Untracked files first

Is it possible to configure git to print Untracked files first when doing git status? Currently, the printout when doing git status is something like stated below. Note: I do not want to use the ignore functionality. All files that are untracked shall be printed.

# Changes to be committed:
#  (use "git reset HEAD <file>..." to unstage)
#
#   modified:   somefile.c
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   anotherfile.c
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    Alot of files.
#   .
#   .
#   .

Upvotes: 1

Views: 171

Answers (1)

user456814
user456814

Reputation:

If you have a sort command available that sorts in reverse, you could try this:

git status --short | sort -r

which gives this output in msysgit 1.9.0:

?? foo.txt
 M hello.scala

In the output above, untracked files are shown with ?? before them. As the documentation states:

For untracked paths, XY are ??.

Also note that the short form of the --short flag is -s, so this can also be used:

git status -s | sort -r

Aliases

If you want, you could even turn this into a git alias:

git config --global rstatus "!git status --short | sort -r"

# Usage
git rstatus

Or you could define an alias in your Bash config:

alias gsr='git status --short | sort -r'

# Usage
grs

Upvotes: 1

Related Questions