Vacassal Alsk Vacassal Alsk - 14 days ago 6x
Git Question

commit folder in the untracked folder

in git large file system, I have untracked some folder, say folder1, say it contains very huge trunks (a lot large of folders) of things... I have previously untracked it to avoid errors (since I even after i just git pull and git push, it would say it has changed and push tons of things online which is complete waste of resources). ok now, I have added something in folder 1 locally, say:


I want to only commit folder1/important_update1 but nothing else... What should I do?

should i just do:

git commmit folder1/important_update1
git push


You can add the file using git add -f folder1/important_update1 and commit your changes afterwards. In the future your changes to that file will not be ignored.

You could also ignore the contents of folder1 and exclude important_update1 from that using these entries in your .gitignore:


The first line is important as you can not exclude files if their parent directory has been ignored before (so this wouldn't work if the first line were just folder1).

The latter method might be useful if you want to "unignore" all files matching a specific pattern, e.g. use !folder1/important_update* to avoid ignoring all files and folders starting with important_update within folder1.