Including untracked files in new directories in git status output

git status shows the status of the workspace – like which files have been modified or which files are new. For new directories with new files in them, the default behavior is to only show the directory name – but not the contents of the directory:

$ mkdir -p newDir/subDir
$ touch newDir/newFile1 newDir/newFile2 newDir/subDir/newFile3
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       newDir/
nothing added to commit but untracked files present (use "git add" to track)

I usually prefer to also see the contents of the directories – this can be achieved by adding the parameter --untracked-files=all to git status:

$ git status --untracked-files=all
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       newDir/newFile1
#       newDir/newFile2
#       newDir/subDir/newFile3
nothing added to commit but untracked files present (use "git add" to track)

It is a littlebit cumbersome to type this parameter each time, but Git allows to define aliases for commands. Straightforward, we can try to add the following alias to ~/.gitconfig:

[alias]
        status = status --untracked-files=all

Unfortunately, this will not work – Git does not allow to redefine existing commands (see “alias.*” at https://git-scm.com/docs/git-config). Some commands allow to add default parameters in ~/.gitconfig, in a format similar to

[status]
        untracked-files=all

but again, for status, this does not work. The simplest way is to just define a new command alias, like

[alias]
        statusall = status --untracked-files=all

This will not change the default behaviour of the status command (which is probably good, since scripts might rely on the default output format of the command), but it simplifies the above command line:

$ git statusall
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       newDir/newFile1
#       newDir/newFile2
#       newDir/subDir/newFile3
nothing added to commit but untracked files present (use "git add" to track)