is git unable to commit a device file? Under Linux system.

For example:

git clone [email protected]:/blah.git
cd blah 
sudo cp -af /dev/ttyS0 .
git add .
git commit

git msg:

# On branch master
nothing to commit (working directory clean)

ls -ashl result:

   0 crw-rw----  1 c2h2 c2h2 4, 64 Jun 24 14:23 ttyS0

Is it possible to do so?

1 Answer 1


No, Git will not track device files at all (currently). Here's a comment from dir.c, read_directory_recursive (v1.7.8.5) function which is used when you do git add .:

 * 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.

Git tracks contents, not files. So trying to make it track device files doesn't really fit - they don't really have content in a traditional sense.

An approach that would work is to create a script that creates/"installs" the device files your application/project needs (including fifos or whatever else you might need). Git can track that very effectively, and it's a handy form to have that in for an installer (or for other people using your tree).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .