我正在编写一个脚本来查找添加到舞台的所有文件。我只提出了在已经有初始提交时才有效的解决方案(即使用 git diff-index --name-status HEAD)。但是没有 HEAD 时没有解决方案。
IE:
% git init
Initialized empty Git repository in /Users/jocke/dev/agical/test/.git/
% cat >> test
content
^C
% git add --all
% git st
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: test
#
% git diff-index --name-status HEAD
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
git status 似乎能够弄清楚需要添加什么。可能有一些我可以使用的管道,但我似乎找不到它。有任何想法吗?