What is the exact the procedure you have to follow using git? I will give my procedure (which is, somehow, not working very smoothly):
- cloned a repository: (works fine)
- added settings files to .gitignore to prevent overwriting the originial
settingfiles on the remote (= test environment)
- made changes to my local repository and committed it locally (works fine)
- pushed it from local to remote (did not work properly)
When pushing to the remote the settingfiles on the remote are deleted, which caused my test envirnment to die. I just want the settings files to be ignored if I push and not deleted.
What did I do wrong/forget? Any ideas?
from what i understand, the settingsfile was already tracked in the git repo that you cloned. this means that even if you add it to
.gitignore, it will still be tracked.to remove the file from the history, and make sure it’s ignored in the future you should
.gitignore(as you already did)git filter-branch --index-filter 'git rm --cached --ignore-unmatch settingsfile' HEADnote that you need to run the above command for each of the branches where the file is present.
then you need to
git push -f origin master(ifmasteris the name of the branch, andoriginthe name of the remote)you can refer to this guide for additional info.
Also, as Rafid K. Abdullah said, you haven’t deleted anything (if you have followed the workflow you describe in your post); you have just added modifications that you can easily revert. that’s what git is for after all 🙂