如何从另一个文件夹中减去文件夹和文件列表? [英] How to subtract folders and files list from another one?
问题描述
我有一个git repo,如下所示:
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
很容易获得git跟踪的文件夹和文件的列表.
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
但是在工作目录中,有些文件夹和文件没有被git跟踪.整个工作目录如下:
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
如何获取未由git跟踪的文件夹和文件列表,如下所示::
archiver/
archiver/index.php
api/remote/index.htm
api/remote/index.php
我想在rsync -av --files-from=/path/to/not_tracked_files_lsit
中使用此列表.
预先感谢!
I want to use this list in rsync -av --files-from=/path/to/not_tracked_files_lsit
.
Thanks in advance!
推荐答案
基本上从上面的注释中复制...
Basically copying in from comments above...
find
将为您提供完整的文件列表.
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.
这篇关于如何从另一个文件夹中减去文件夹和文件列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!