Questions tagged [git-ls-files]
42 questions
460
votes
10 answers
Git: list only "untracked" files (also, custom commands)
Is there a way to use a command like git ls-files to show only untracked files?
The reason I'm asking is because I use the following command to process all deleted files:
git ls-files -d | xargs git rm
I'd like something similar for untracked…

We Are All Monica
- 13,000
- 8
- 46
- 72
46
votes
1 answer
git ls-files in bare repository
I want to access a bare git repository, and I want to list all files in the repository.
On a normal git repository I can easily do that by running git ls-files.
Example output:
$ git…

Jesper Rønn-Jensen
- 106,591
- 44
- 118
- 155
13
votes
2 answers
git ls-files, how to escape spaces in files paths?
A whole BUNCH of files got checked into our git repo before we introduced the .gitignore file. I'm currently trying to clean it up with:
git rm --cached `git ls-files -i --exclude-from=.gitignore`
The thing is MANY of the file paths have spaces…

Sean Novak
- 510
- 2
- 14
7
votes
1 answer
Is comparing git lfs ls-files with git ls-files ':(attr:filter=lfs)' a reliable way to detect lfs files that are not managed by lfs?
I try to find a way to determine whether the files in git repository are correctly managed by git-lfs.
So far, I have found that comparing results from git lfs ls-files and git ls-files ':(attr:filter=lfs)' seems to give me what I want.
Add-Type…

Eugene Podskal
- 10,270
- 5
- 31
- 53
5
votes
1 answer
List last edits of all file by a collection of users
Question: Given a git repo, show the files modified by a specific set of users, plus the last editor (from that set of users) of those files.
Potential solution:
git ls-files | xargs -n 1 git log -1 --author="example.com" --name-only…

stephenfin
- 1,447
- 3
- 20
- 41
4
votes
1 answer
How an I make `git ls-files` work in subdirectories?
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…

oarfish
- 4,116
- 4
- 37
- 66
4
votes
2 answers
git ls-files for different branch
I want to find all markdown files in the base directory of a specified branch. git ls-files was suggested to me, but the documentation doesn't mention specifying a branch. I want to be able to do this without checking out that branch. Can this be…

Pi Fisher
- 260
- 1
- 11
4
votes
1 answer
What is the meaning of the different fields in the output of `git ls-files -s`?
In Git, a typical line of the result returned by command git ls-files -s looks like
100755 be2c2e9b0966253096472d4b482c458bc892e493 0 .gitignore
What do those fields mean?

qazwsx
- 25,536
- 30
- 72
- 106
3
votes
2 answers
Possible to read file from git cache?
I can see list of files using below command
git ls-files --cache
Wondering if it's possible to read the content of the listed file?

Isaac
- 12,042
- 16
- 52
- 116
3
votes
1 answer
git fails to stage files, show all files as duplicate but the char casing is not an issue
In my case, I did simple one liner change to one of my file and wanted to commit my changes but noticed that commit -am "" did not add/commited the file.
After issuing git ls-files --stage, I see probably all files in my project showing as…

pixel
- 9,653
- 16
- 82
- 149
3
votes
1 answer
Git ls-files behaviour
It's not clear how git ls-files using wildcards actually functions.
I started with the git ls-files *.* command which works okay. It shows all the files under version control in all the underlying subdirectories
But now I want to select a set of…

Mark de Bont
- 33
- 6
2
votes
2 answers
How to compare local and remote git files?
I need to list all tracked commited files that only exist locally. Let's say my local repo is a commit forward the remote repo (on github or gitlab) and these are my local tracked commited files:
a.txt
b.txt
Now imagine in my remote repo there is…

Fernando Costa
- 669
- 1
- 9
- 31
2
votes
3 answers
git ls-files - undocumented syntax that queries files based on their .gitattributes - git ls-files ':(attr:filter=lfs)'
Is comparing git lfs ls-files with git ls-files ':(attr:filter=lfs)' a reliable way to detect lfs files that are not managed by lfs? uses git ls-files syntax that queries files based on their .gitattributes (in that particular case on…

Eugene Podskal
- 10,270
- 5
- 31
- 53
2
votes
1 answer
Git - List files recursively by branch/tag name
I want to see file trees without cloning all remote files. Is it possible using git commands?
git version 2.21.0
My current commands are below:
- mkdir my-repo && cd my-repo
- git init
- git remote add origin https://remote-repo-url
- git fetch
-…

zakjma
- 2,030
- 12
- 40
- 81
2
votes
2 answers
Exclude files staged as deleted fom `git ls-files`
I use git ls-files in a script to collect all files tracked by git. Unfortunately if you rm a file (rather than git rm) it does not exist on the file system any more but it will still be listed by git ls-files
So the question: Is there a simple and…

frans
- 8,868
- 11
- 58
- 132