Make git status show unmodified/unchanged tracked files?
git, version-control
Solution
Quick one-liner that works on Linux and on a Mac:
`sort -uk 2bi <(git status -s) <(git ls-files | sed 's/^/ . /')`
You can wrap this in an convenient alias that also accepts an optional directory path. So under `[alias]` in your `.gitconfig` you can put this:
stt = "!f() { cd -- ${GIT_PREFIX}/${1:-.} ; sort -uk 2bi <(git status -s .) <(git ls-files . | sed 's/^/ . /') ; }; f"
Then you can use it something like this:
$ git stt
$ git stt src/foo
$ git stt ..
Problem
Here is a brief snippet example (which you can paste in your Linux terminal), creating a new `git` repository and adding some files to it (using git version 1.7.9.5): ``` cd /tmp/ mkdir myrepo_git cd myrepo_git/ git init git config user.name "Your Name" git config user.email you@example.com echo "test" > file_tracked_unchanged.txt echo "test" > file_tracked_changed.txt echo "test" > file_untracked.txt git add file_tracked_unchanged.txt git add file_tracked_changed.txt git commit -m "initial commit" ``` Now, after the initial commit, I want to change the `file_tracked_changed.txt` files, and keep the others (here, only `file_tracked_unchanged.txt`) unchanged for the next commit. Below is a snippet which demonstrates that, and the diverse outputs of `git status` vs `git ls-files` (`git` shell output is prefixed with `#`): ``` echo "test more" >> file_tracked_changed.txt git status -uno # # On branch master # # 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: file_tracked_changed.txt # # # no changes added to commit (use "git add" and/or "git commit -a") git status # # On branch master # # 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: file_tracked_changed.txt # # # # Untracked files: # # (use "git add <file>..." to include in what will be committed) # # # # file_untracked.txt # no changes added to commit (use "git add" and/or "git commit -a") git status -uno --short # M file_tracked_changed.txt git status --short # M file_tracked_changed.txt # ?? file_untracked.txt git ls-files -v # H file_tracked_changed.txt # H file_tracked_unchanged.txt git add file_tracked_changed.txt git status -uno # # On branch master # # Changes to be committed: # # (use "git reset HEAD <file>..." to unstage) # # # # modified: file_tracked_changed.txt # # # # Untracked files not listed (use -u option to show untracked files) git status # # On branch master # # Changes to be committed: # # (use "git reset HEAD <file>..." to unstage) # # # # modified: file_tracked_changed.txt # # # # Untracked files: # # (use "git add <file>..." to include in what will be committed) # # # # file_untracked.txt git status -uno --short # M file_tracked_changed.txt git status --short # M file_tracked_changed.txt # ?? file_untracked.txt git ls-files -v # H file_tracked_changed.txt # H file_tracked_unchanged.txt ``` What I'm looking for, is a command which will show all tracked files in a directory (which `git ls-files -v` does), with their accurate repository status (which `git ls-files` doesn't show, as it shows `H` as status for all tracked files). For instance, I'd like to obtain something like the pseudocode: ``` git status-tracked # M file_tracked_changed.txt # . file_tracked_unchanged.txt ``` ... where the dot `.` would a symbol indicating a tracked, but unchanged file (if I recall correctly, SVN may use a `U` character for these). Ultimately, I'd like to also show the status of all files in a directory, as in the pseudocode: ``` git status-tracked-and-untracked # M file_tracked_changed.txt # . file_tracked_unchanged.txt # ?? file_untracked.txt ``` ... but it's more important to me to get to the status of all tracked files, as in the pseudo `git status-tracked` above. Any command in `git`, that already does something like this?