I init folder. Added all files commit them and than push them. Everything was looking fine...but i am missing some files and folder.
To example my .gitignore file
web/images/uploaded_profile_pictures/*
But there should be uploaded_profile_pictures folder... how to write it in .gitignore to ignore ONLY the content of the folder.. and keep the folder?
And second problem... why is there missing content???
After push
There can't be folders without files in Git repositories, Git will always ignore empty folders (or folders that contain only ignored files). A common workaround is to create placeholder files in empty directories that you want to include in your Git repository.
touch web/images/uploaded_profile_pictures/.empty
git add web/images/uploaded_profile_pictures/.empty
Now for the .gitignore
:
web/images/uploaded_profile_pictures/*
!web/images/uploaded_profile_pictures/.empty
# or just
!.empty
This will make Git ignore all files in that folder except of .empty
, allowing you to add the folder to the repo.
For the second question: What kind of files are missing? Are those just random ones?
As @Uroc327 mentioned in his comment, git doesn't handle "folders and files" but instead it uses "content".
This means that an empty folder is simply non existent to git.
This is a common problem, and the simplest solution is to add some "fake content" (an empty file) to a folder.
As @jwhy said, you could create a file named empty
.
A more elegant approach (in my opinion) would be having in the folder web/images/uploaded_profile_pictures
a file named .gitignore
which contains the following:
*
!.gitignore
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With