0

I have a git repo as below:

[root@localhost www]# tree
.
├── admin.php
├── api
    ├── index.htm
    └── remote
        └── mod
            ├── index.htm
            ├── mod_cron.php
            └── mod_index.php


3 directories, 5 files

It's easy to get the list of folder and files tracked by git.

[root@localhost www]# git ls-files >a.txt
[root@localhost www]# cat a.txt
.gitattributes
.gitignore
admin.php
api/index.htm
api/remote/mod/index.htm
api/remote/mod/mod_cron.php
api/remote/mod/mod_index.php

But in working direcotry, there's some folders and files not tracked by git.Whole working direcotry as below:

    [root@localhost www]# tree
    .
    ├── admin.php
    ├── api
    │   ├── index.htm
    │   └── remote
    │       ├── index.htm
    │       ├── index.php
    │       └── mod
    │           ├── index.htm
    │           ├── mod_cron.php
    │           └── mod_index.php
    ├── archiver
       └── index.php

4 directories, 8 files

How to get the list of folders and files not tracked by git as below:

archiver/
archiver/index.php
api/remote/index.htm
api/remote/index.php

I want to use this list in rsync -av --files-from=/path/to/not_tracked_files_lsit.
Thanks in advance!

kittygirl
  • 2,255
  • 5
  • 24
  • 52

1 Answers1

0

Basically copying in from comments above...

A find would give you a complete list of files present.

find | grep -v '[.]git/' | grep -vf a.txt

should eliminate the crap from the repo itself and all the tracked files.

Another option, probably better:

git status -s | sed -n '/^[^?]/d; s/^?? //; p;'

That should do much the same thing but hopefully a little cleaner and more to the point, with fewer processes in the pipeline.

Paul Hodges
  • 13,382
  • 1
  • 17
  • 36