GarouDan GarouDan - 3 months ago 19
Git Question

Git. How to add all files that are not those returning error?

Using linux, I would like to do something like in the script below using git:

cd /
sudo git init .
sudo git add -A
sudo git commit -m "Genesis."


I would like to do this to see which files are changed in the filesystem when I install some software and for another purposes of mine.

But when I try
sudo git add -A
I receive some error messages like:

error: readlink("proc/10/exe"): No such file or directory
error: unable to index file proc/10/exe
fatal: adding files failed


But this is OK, probably /proc files will not help me so much.
So I would simple add all files but ignoring the files that I receive errors.
I tried
sudo git add -A --ignore-errors
and a bigger output had come, unfortunately when running
git status
nothing happened.

So, how could I add all files that will not cause errors to achieve what I need?

Answer

After trying several things looks like I'd reached an answer:

sudo find * -type f | sudo xargs git add

This operation took a long time but worked. The truth is I ran sudo find {folder here} -type f | sudo xargs git add to each folder in /.

I was trying to do this on a vagrant VM (ubuntu/trusty64) and after the operation the .git folder was with about 600MB.

Then I searched for a command to get all files that was not tracked and add them to .gitignore.

So I used this:

sudo git status -s | grep -e "^\?\?" | grep -v ".gitignore" | cut -c 4- >> .gitignore

Unfortunately 7 pem "files" was not put in the .gitignore:

    "etc/ssl/certs/AC_Ra\303\255z_Certic\303\241mara_S.A..pem"
    "etc/ssl/certs/Certinomis_-_Autorit\303\251_Racine.pem"
    "etc/ssl/certs/EBG_Elektronik_Sertifika_Hizmet_Sa\304\237lay\304\261c\304\261s\304\261.pem"
    "etc/ssl/certs/NetLock_Arany_=Class_Gold=_F\305\221tan\303\272s\303\255tv\303\241ny.pem"
    "etc/ssl/certs/T\303\234B\304\260TAK_UEKAE_K\303\266k_Sertifika_Hizmet_Sa\304\237lay\304\261c\304\261s\304\261_-_S\303\274r\303\274m_3.pem"
    "etc/ssl/certs/T\303\234RKTRUST_Elektronik_Sertifika_Hizmet_Sa\304\237lay\304\261c\304\261s\304\261_H5.pem"
    "etc/ssl/certs/T\303\234RKTRUST_Elektronik_Sertifika_Hizmet_Sa\304\237lay\304\261c\304\261s\304\261_H6.pem"

I tried put them manually but didn't work. But I think, for inspection purposes, this will not be a problem.

If is there a way to put this files in .gitignore I would like to know.

Thanks for help.