Answer the question
In order to leave comments, you need to log in
Removing files from git version control: why does git remove files that are out of its control?
I want to remove a file from version control, it's about the .htaccess file, but I don't want to remove the file itself.
That's why I use the following commands in my repository:
git rm --cached htaccess
git add .
git commit -m "removed the .htaccess file from version control"
git push
on this server the .htaccess file remains intact
-----
these changes end up in the remote repository
----
on the other server I get these changes with
git pull
in As a result, git removes the .htaccess file from the server that received the changes
AND I restore the .htacces for it from a backup, why is this happening? why does git delete a file?
Answer the question
In order to leave comments, you need to log in
you still need to add to .gitignore.
git commits and removes the file.
It does not delete on your machine, because `--cached`
No way. Git is instructed by you to delete the file (it leaves it on your copy with the --cached switch).
When merging the changes, he repeats this at another site and deletes the file (this time without saving, because he does not remember this key for everyone, for him it is just a deletion).
You need to delete this file, add it to .gitignore and then manually add it back on each site after deletion.
Or you need to do git rm --cached on each site, then when merging, Git will see that the file has already been deleted and will not do anything with it.
It's a chore, but I myself did not find another way.
in .gitignore first of all added. And how to make sure that it does not delete on others too?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question