0

The title says it all.

For a simple example: at time t1, the repository contains files with extensions .A and .B. At a later time t2, we decide to add .B extensions to the .gitignore file. I'd like to list files with extension .B currently under version control (not to remove them, just to know if/where they are).

Of course in my case it's not just one extension but many different patterns that have been added to the .gitignore. And it is also something useful to know for general maintenance purposes.

Note: I'm not interested in ignored files not under version control, I know you can list those using git status -i.

Jonathan H
  • 7,591
  • 5
  • 47
  • 80
  • Are you using a UNIX machine? (Mac, Linux, etc.) – Harmelodic Mar 23 '16 at 14:32
  • Probably related to https://stackoverflow.com/q/2994612/321973 – Tobias Kienzler Mar 23 '16 at 14:33
  • @Harmelodic Linux/osx but if you're going to recommend `find`, I'd like to stress that it's a collection of ignore patterns, not one extension. – Jonathan H Mar 23 '16 at 14:33
  • @TobiasKienzler Unless I misunderstand the post you linked, I think it's about listing ignored files, not ignored files under version control. – Jonathan H Mar 23 '16 at 14:34
  • I was going suggest `ls *.{B, , }` to list the files with those extensions. However, listing files that are inside a specifically inside a .git-ignore file, I'm not aware of. – Harmelodic Mar 23 '16 at 14:36
  • 1
    Yup, but one of the answers there also mentions `git ls-files --ignored --exclude-standard`, which appears to be what you wanted – Tobias Kienzler Mar 23 '16 at 14:39

2 Answers2

2

This should do the job for you as you mentioned the files are already under version control - if they are new, than just add --others to the command.

git ls-files -i --exclude-standard
DAXaholic
  • 33,312
  • 6
  • 76
  • 74
0

You don't have to add them to .giignore, you can also use this:

--[no-]assume-unchanged

When this flag is specified, the object names recorded for the paths are not updated.

Instead, this option sets/unsets the "assume unchanged" bit for the paths.

When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

In case you need to print out list of files marked with the --assume-unchanged flag:

git ls-files -v|grep '^h'

enter image description here

CodeWizard
  • 128,036
  • 21
  • 144
  • 167