We are using Git in our organization to update codes on the servers for all projects. Often, developers forget to ignore the files which should be ignored (like db config or data etc.) and push them to our Git server. Which later gets synced to the actual server where code runs (with the help of hooks). git pull
is executed on the server to get the latest code.
Now, if I add any specific file to .gitignore
and remove it from index
and push
it to the server using below commands.
git rm --cached config.php
git add .gitignore
git commit -m "removed config file and ignored it"
git push origin master
This will remove the file from Git but not from my local repo. It will also prevent it from being tracked further.
Then, git pull
is executed on the server which is removing the newly ignored file causing issues. Simple pull
command is executed on the server as below:
git pull origin master
I do not want to remove config.php
file from the server while removing it from git remote repository.
Sometimes I remove large number of files in the same way which should remain on server (where code runs).
What would be the easiest and programmable solution for this ? I have developed a Node.js program which logs in to the server and runs pull
command there programmatically.