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?
Why does `git update-index` not affect files not in the current directory?
103 Views Asked by planetp At
2
There are 2 best solutions below
0

As a note, one way to run git commands from the top of the work tree is to add an alias that gets it done there:
git config --global alias.attop '!git'
and then you can git attop update-index --again
, I also have !true;
as an alias so I can git exec anycommand
to run find or whatever at the top of the work tree.
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
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 onlyfile3
is re-staged - notfile1
. But if we saidthis will apply the command from the root of the worktree.