I'm trying to use git update-index --again
to re-add modified files to the index. This works fine, but only for files/directories in the current directory. Is this expected behavior for this command or is there any option to make it consider the whole repository?
This appears (in my tests) to work just like any typical git command. That is, it defaults to the current working directory and subdirectories (recursively), and you can specify paths if you want something different. If that's not the behavior you're seeing, please clarify with more specifics and I can take another look at it.
So for example
# 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
Becuse we're in the dir
directory, the default (like with most git commands that take paths) is to default to the current directory. So only file3
is re-staged - not file1
. But if we said
git update-index --again :/:
this will apply the command from the root of the worktree.