I want to run git ls-file --modified
to obtain a list of files with unstaged changes. I was surprised to find that it works in the root directory, but not in any subdirectory, where it only prints files from the subdirectory (in contrast to git status
, for instance).
Steps to reproduce:
mkdir repo
cd repo
git init
touch file.txt
git add file.txt
mkdir subdirectory
echo "foo" >> file.txt # file now has unstaged changes
git ls-files --modified # This prints 'file.txt'
cd subdirectory/
git ls-files --modified # This prints nothing
How can I change git's behaviour here?