C
C
Cat Anton2016-01-13 10:57:27
git
Cat Anton, 2016-01-13 10:57:27

How to get a list of monitored and indexed files and directories in Git, excluding subdirectories?

Good.
Problem You
need to get a list of the names of all monitored and indexed files and directories in the current directory, excluding all subdirectories.
For example, for a structure like this:

/.git/...
/folder/subfolder/file.ext
/folder2/new.ext (новый проиндексированный файл)
/.gitignore
/file.ext
/ignoreme.ext (не отслеживаемый файл)
/new.ext (ещё один новый проиндексированный файл)

Need to get:
folder
folder2
.gitignore
file.ext
new.ext

What I have already tried
The command gives a very close result git ls-tree --name-only HEAD
. But it does not return the names of new, indexed files and directories with such files.
I also looked to the side I git ls-files
played with the parameters, but I did not manage to achieve the required result.
Why is this needed at all?
I am writing a script that generates a README.md file for each subdirectory, which will include a list of all files and directories in this directory with brief explanations. Explanations are taken from the config or based on the contents of a directory or file.
Thanks in advance to everyone for any ideas.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Io, 2016-01-13
@vawsan

The script temporarily put all subfolders in .gitignore, track, and then rollback the .gitignore file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question