Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add all files using git add except one directory

Tags:

git

I am trying to add all the files to my git index using

git add -A 

However, there is one directory with very large files that is causing this error:

fatal: confused by unstable object source data for 9f8c02a8d2a04d7fffed08b299a0cb8996ab7ecb 

Therefore, the adding process is broken! How can I tell git I want to exclude this directory while adding everything else? Available online solutions first add everything and then remove some files. Obviously, I cannot do this because git crashes while adding the files in that specific directory.

like image 406
Moh Avatar asked May 13 '18 13:05

Moh


People also ask

How do I exclude files from git add?

Set “–assume-unchanged” to a path to exclude to check on git commit and it will exclude your file from git commit. You will need to use the git update-index and –assume-unchanged to exclude files from git commit.

Can you do git add for multiple files?

You can add all the files using the git add command like below for all the files you want to add, which will add all your files to the staging area, which means the files are ready to be committed. Now commit your files, the editions or addition made in the files will now be saved.


1 Answers

If your Git version is new enough,

git add -- . ':!<path>' 

. means all under the current directory, and ':!<path>' means to exclude the path. So it means to add all except path.

like image 68
ElpieKay Avatar answered Oct 16 '22 01:10

ElpieKay