Reputation: 1189
Hi i have a bare repo and 2 user got clone from that repo ,
after a while i founded that i need to ignore tracking images from a folder but we want to every client have that folder for themselves and not remove, [like storing product images]
so i add the folder to gitignore and then we need only bare repo to not have any images ,
so i searched and founded to remove pictures that before added we should use
git rm --cached folder/
so after using this command the client that used this command have that folder and every thing is ok
but another client run git pull
and see the local folder removed !
so what should we do that pictures only remove from bare repo, not clients that use git pull
Upvotes: 0
Views: 1608
Reputation: 4265
To get around this, create the folder/
and add a file called empty
, as git needs a file in a folder structure for it to exist.
In your .gitignore file, you'll have the ignore line folder
. Right below that add a new line !folder/empty
which will then mean ignore items in 'folder', but not the 'empty' file.
The same can be done with a blank index.html file or similar.
Upvotes: 0
Reputation: 521073
I think what happened is that the first client used git rm
on the folders, then pushed, removing them from the branch on the repository. Then, when another client pulled, Git effectively sent a delete order to those image files, thereby removing them from the second client's local files.
To avoid this happening for other clients, each client should first add the image files to .gitignore
before pulling. This way, when Git sends an order during the pull to delete the files, the files will be ignored and they will remain locally.
Upvotes: 0