Re: Fwd: git status options feature suggestion
- From
- Fyn Fynn <fynfynn@gmail.com>
- Date
- Oct 18, 2008, 00:19 UTC
- Message-ID
- <1a04eebf0810171719r6b604a88n781bf43f0f047aae@mail.gmail.com>
- In-Reply-To
- <ee2a733e0810120309o1fbfa4dxe6f2292a28bd6db3@mail.gmail.com>
Just wanted to chime in about a feature existing in Bazaar's and Subversion's and "status" command: getting the status of tracked files _only_.
Here's how the status -V switch works in Bazaar:
~/foo$ bzr init ~/foo$ echo "content" > bar.txt ~/foo$ bzr add bar.txt added bar.txt ~/foo$ echo "content" > baz.txt ~/foo$ bzr status added: bar.txt unknown: baz.txt ~/foo$ bzr status -V added: bar.txt
As you can see, the -V switch makes `bzr status` only display the status of files that are tracked.
This is very useful when you're tracking a "skeleton" of essential files in a directory tree that contains a large number of additional files and subdirectories, particularly if those are changing often and / or are large/binary so it's impractical to control/ignore them.
A common case of that: tracking a subset of configuration files under one's home directory.
Right now, there are two ways of getting around the lack of "status -V" (Subversion: "status -q") in git (credit for both goes to doener on #git@FreeNode, who showed them to me):
git config --global alias.st 'diff --name-status HEAD'
Which makes `git st` output practically the same thing as -V/-q in Bazaar/Subversion. However, the output doesn't distinguish between Staged (indexed) and Unstaged (non-indexed) changes (a distinction that the 2 other SCMs above don't support).
git config --global alias.st '!echo Staged:; git diff --cached --name-status; echo Unstaged:; git diff --name-status'
Which does distinguish between Staged and Unstaged, but is definitely something that can work only as an alias for frequent usage.
Incidentally, a minor quibble with both solutions is that they require HEAD to exist; so you need to make at least one commit before you can use them. For most users, this wouldn't frequently be a huge loss, but if you're commonly initializing branches, you might miss it. For example, note how the above Bazaar example would fail with:
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
- Fyn