Mat*_*tis 92
git status .
Run Code Online (Sandbox Code Playgroud)
将显示当前目录和子目录的状态.
例如,此树中的给定文件(数字):
a/1
a/2
b/3
b/4
b/c/5
b/c/6
Run Code Online (Sandbox Code Playgroud)
从子目录"b",git status显示整个树中的新文件:
% git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: ../a/1
# new file: ../a/2
# new file: 3
# new file: 4
# new file: c/5
# new file: c/6
#
Run Code Online (Sandbox Code Playgroud)
但git status .只是在"b"及以下显示文件.
% git status .
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: 3
# new file: 4
# new file: c/5
# new file: c/6
#
Run Code Online (Sandbox Code Playgroud)
git status .以递归方式显示"b"以下的所有文件.要仅显示"b"中的文件而不是下面的文件,您需要将文件列表(而不是目录)传递给git status.这有点繁琐,取决于你的shell.
在zsh中,您可以使用"glob限定符"选择普通文件(.).例如:
% git status *(.)
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 3
new file: 4
Run Code Online (Sandbox Code Playgroud)
Bash没有glob限定符,但是你可以使用GNU find来选择普通文件,然后将它们传递给git status像:
bash-3.2$ find . -type f -maxdepth 1 -exec git status {} +
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 3
new file: 4
Run Code Online (Sandbox Code Playgroud)
这使用-maxdepth了GNU查找扩展.POSIX查找没有-maxdepth,但你可以这样做:
bash-3.2$ find . -path '*/*' -prune -type f -exec git status {} +
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 3
new file: 4
Run Code Online (Sandbox Code Playgroud)
It is possible to restrict git status to the current directory (without child folders) by giving a pathspec using the magic word glob and *::
git status ':(glob)*'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23029 次 |
| 最近记录: |