Reputation:
I have a website. Users can add a picture their profile. So, my website keeping these files in a folder. But, my local git clone only has this image folder without images inside.
When I use "git push" command, it's working great but deleting all images added by users.. How can I solve this problem? [Or, how can I add images (added by users) to git tracking?]
(I'm using openShift)
Upvotes: 0
Views: 125
Reputation: 7613
You need to use the OPENSHIFT_DATA_DIR to save persistent files. Use a symlink in link it to one of your folders in the repo.
Edit
post_deploy example
#!/bin/bash
echo ".................Starting 'post_deploy' Action Hook..................................."
echo ".................attempting 'uploads' setting up symlink........................"
echo "................................................................................"
cd $OPENSHIFT_REPO_DIR/<path to static folder>
ln -s $OPENSHIFT_DATA_DIR/uploads uploads
echo ".................creating 'uploads' completed........................"
echo "................................................................................"
Upvotes: 1
Reputation: 9884
Git works on files, not on folders. And if a folder does not contain any files, git assumes the folder itself should not be present either.
The most commonly used solution is an empty file .gitkeep
in the folder that needs to remain. Then, in .gitignore
, you add the following:
images_folder/*
!images_folder/.gitkeep
This tells git to ignore all files in the images folder, except for the one file named .gitkeep
. (So that file must be committed too.) Then there's no reason for git to remove the folder, so your images will remain.
Upvotes: 0
Reputation: 19816
You can either skip that folder when you run git add
command or the better add it to .gitignore
file like this:
your_folder/*
Upvotes: 0