Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8031343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:04:29+00:00 2026-06-05T01:04:29+00:00

I want to list the files currently tracked in a git repository. So, I

  • 0

I want to list the files currently tracked in a git repository.

So, I do git ls-files. However doing so, gives me the entire list including all the sub-directories, their sub-directories and so on..

I do not want this. Is there a way where I can specify the depth of the output of ls-files command?

Suppose I have a git repo:

mainrepo/
   sub-dir1
       subdir1.1
          subdir1.1.1
   sub-dir2

I only want to go to depth 1, perse. That means I only want ls-files to ouput

sub-dir1
sub-dir2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:04:31+00:00Added an answer on June 5, 2026 at 1:04 am

    A somewhat rudimentary way is to strip each line up to (and including) an optional / character, and get the unique lines from that:

    $ git ls-files | cut -f1 -d/ | uniq
    

    (Note that I haven’t been able to test this personally yet, because I’m on Windows using a limited Bash shell.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to list all files in a directory Using PyroCMS. Using the Files
I want to list all files on an FTP server using PHP. According to
I want to list all .xml files in a dir and its subdir. I
Is there a command in mercurial that will list all files currently under source
git 1.7.12 I want to mark all files below a given directory as assume-unchanged.
I want to safe resolve all the files in a pending changelist. Currently, the
i want to list files from dev end at tty bettwen 15 and 24...should
I want to generate a list of files where the name consists of ${filename}.${date}
I want to get a list of files and then read the results into
I want to list a names of the files and put them into String

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.