Search code examples
gitpathgit-submodulesabsolute-pathgit-ls-files

How to get the absolute path of all files in a Git repository with submodules?


I am trying to list all untracked files in all submodules recursively:

git submodule foreach --recursive git ls-files --others --exclude-standard --full-name

But this does not list the absolute path, it gives the relative path to the submodule's folder.

How should I modify my command?


Solution

  • Thanks to torek for the idea. This works:

    git submodule foreach --quiet 'a=$(printf "$(git ls-files --others --exclude-standard --full-name|sed "s~^~$(pwd)/~")"; printf x); a=${a%x}; echo "$a"' | sed '/^\s*$/d'