【发布时间】:2019-01-04 14:24:50
【问题描述】:
我有一个如下的 git repo:
[root@localhost www]# tree
.
├── admin.php
├── api
├── index.htm
└── remote
└── mod
├── index.htm
├── mod_cron.php
└── mod_index.php
3 directories, 5 files
获取 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跟踪。整个工作目录如下:
[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 中使用此列表。
提前致谢!
【问题讨论】:
-
a
find会给你一个完整的文件列表。grep -vf a.txt应该消除被跟踪的文件。 -
另一种可能的选择:
git status -s|sed -n '/^[^?]/d; s/^?? //; p;' -
@PaulHodges,为什么不添加答案
-
只是觉得有人可能会提供更好的,但会做到的。
-
git ls-files -o?