0

我正在尝试使用git update-index --again将修改后的文件重新添加到索引中。这工作正常,但仅适用于当前目录中的文件/目录。这是该命令的预期行为还是有任何选项可以使其考虑整个存储库?

4

2 回答 2

0

需要注意的是,从工作树的顶部运行 git 命令的一种方法是添加一个别名,让它在那里完成:

git config --global alias.attop '!git'

然后你可以git attop update-index --again,我也有!true;一个别名,所以我可以git exec anycommand在工作树的顶部运行 find 或任何东西。

于 2021-01-21T21:01:45.247 回答
0

这看起来(在我的测试中)就像任何典型的 git 命令一样工作。也就是说,它默认为当前工作目录和子目录(递归),如果你想要不同的东西,你可以指定路径。如果这不是您所看到的行为,请详细说明,我可以再看一下。

所以例如

# setup a repo with some files
git init
touch file1
touch file2
mkdir dir
touch dir/file3
touch dir/file4
git add .
git commit -m "1"

# stage changes for a couple of the files, and make some additional changes
echo foo >file1
git add file1
echo bar >> file1
echo foo > file2
cd dir
echo foo >> file3
git add file3
git echo bar >> file3
git echo foo > file4

# now try it...
git update-index --again

因为我们在dir目录中,所以默认(就像大多数带有路径的 git 命令一样)是默认到当前目录。所以只有file3重新上演 - 不是file1。但是如果我们说

git update-index --again :/:

这将从工作树的根目录应用命令。

于 2021-01-21T20:22:25.627 回答