gpt4 book ai didi

git - 在进行初始提交之前在索引中查找添加的文件

转载 作者:太空狗 更新时间:2023-10-29 14:21:07 24 4
gpt4 key购买 nike

我正在编写一个脚本,用于查找添加到舞台的所有文件。我只提出了在已经有初始提交时有效的解决方案(即使用 git diff-index --name-status HEAD)。但是没有 HEAD 时没有解决方案。

即:

% 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 好像可以搞清楚需要添加什么。可能有一些我可以使用的管道,但我似乎找不到它。有什么想法吗?

最佳答案

所有你想要的是:

git diff --cached --name-status

即使没有初始提交也能正常工作。

或者你想做的:

git status --porcelain

关于git - 在进行初始提交之前在索引中查找添加的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8782226/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com