Suppose we have a directory with a git repository & files:


"inside" files are within git repository, "outside" are not. I'd like to know, how to get the files, that are outside repository and inside.

I know, how to get "inside": I need to run git ls-files, it outputs:


How to get the "outside" files in the same format?

  • How does your example output tell you what's in git and what's outside git? – muru Mar 6 '16 at 1:11
  • the only difference I see in your expected output is that the .git file is not listed. Can you explain in words what you're trying to accomplish? sorting ls output? excluding files from it based on git ls-files output? something else? – Jeff Schaller Mar 6 '16 at 2:04
  • @muru No, I wanted to get 2 outputs: all the files in folder and those who are in git. Then differentiate them using a script. If you know, how to get the files outside git immediately, please, let me know. – user4035 Mar 6 '16 at 8:59
  • @JeffSchaller I am trying to get 2 lists of files: inside git repository and outside git. ls and git ls-files are outputting the data in different formats when they are located inside subdirs. So, I want to find out is it possible to get ls output in the same format as git does. – user4035 Mar 6 '16 at 9:01
  • 1
    You're asking the wrong question in my view, you're in the middle of a solution rather than at the start. You want to write a script, that when it looks at a directory and its contents, including sub-directories, lists all the files and directories which are not included in the git repository which covers the same location, yes? If so - reword your question to that by editing it. – EightBitTony Mar 6 '16 at 9:17

Maybe you can try with git ls-files --others --exclude-standard this should list all files wich are not defined in .gitignore


To get the files outside repository, I had to use git ls-files -o:

$ git ls-files -o
  • Can you please re-word your question so that it actually describes what you're trying to achieve, otherwise it's very likely to be closed. If you reword it, it'll help other people find your question in future. – EightBitTony Mar 6 '16 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.