I have a file config-dev.php which will be used as a dev version config.
Now, another developer wants to make his own changes in this file.
When he commits, this file is commited and my config-dev.php is overwritten by the file from my coworker.
this file is in .gitignore but it is still not working.
How do I remove this file from git index so everyone can have its own config-dev.php?
I tried git rm --cached config-dev.php
but it is still not working. Should this command be executed by all the coworkers? or should I sync after git rm??
To remove a file from Git, you have to remove it from your tracked files (more accurately, remove it from your staging area) and then commit. The git rm command does that, and also removes the file from your working directory so you don't see it as an untracked file the next time around.
In this git gives a suggestion to the user that the tracked file on staging can be removed by using git rm --cached <file> . To practice the command, let's try removing the same CustomerData_IND. txt file, which was added earlier. To remove the desired file, type git rm --cached CustomerData_IND.
remove the file from tracking:
git rm --cached config-dev.php && git commit -m "config-dev.php"
add it to the .gitignore
echo config-dev.php >> .gitignore
git add .gitignore
git commit -m "adding config-dev.php to .gitignore"
Publish these changes
git push
On your colleagues machine fetch the new configuration
git pull
Done
When your other dev gets errors on pull
because of changes in her config-dev.php
, she should copy her local changes away and then rename the file back after pushing:
cp config-dev.php my-config-dev.php
git checkout config-dev.php
git pull
mv my-config-dev.php config-dev.php
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