我运行这个git add --force /dev/cmd将/dev设备添加到我的repo中,得到的git-status与以前一样。我独立地添加文件夹中的每个文件,但得到相同的git状态。
这是我的测试,我得到了相同的结果,git可以跟踪block和char设备吗?

yangchar@yangchar:~/verify$ git add ttyS0 --force
yangchar@yangchar:~/verify$ ll

-rw-r--r-- 1 yangchar yangchar    71 2012-11-28 10:59 hello.c
-rw-r--r-- 1 yangchar yangchar     0 2012-11-28 11:04 new.c
drwxr-xr-x 4 yangchar yangchar  4096 2012-11-28 11:15 ooxx/
-rw-r--r-- 1 yangchar yangchar    31 2012-11-28 10:47 README.md
crw-r----- 1 yangchar yangchar 4, 64 2012-11-28 16:05 ttyS0

yangchar@yangchar:~/verify$ git st

# On branch master

nothing to commit (working directory clean)

最佳答案

不,不能将设备文件添加到Git存储库。以下是git的评论:

/*
 * Read a directory tree. We currently ignore anything but
 * directories, regular files and symlinks. That's because git
 * doesn't handle them at all yet. Maybe that will change some
 * day.
 *
 * Also, we ignore the name ".git" (even if it is not a directory).
 * That likely will not change.
 */

linux中的设备文件是一种特殊的文件,什么使得它们的内容跟踪非常困难(不可能?)是的。

08-27 12:20