What is probably happening is that the program you are using for editing your file creates a new file when saving it, replacing the old file. A newly created file will always be owned by the user that created it.
To work around this (if the program has no obvious way of changing its behaviour), save the file with a new name, then run
cat newname >oldname
to replace the contents of the old file (oldname
) with that of the new file (newname
). It does this by truncating and rewriting the contents without creating a new file. Meta data, such as permissions and ownership, would not change. Then delete newname
.
The other more obvious solution is to use something like git
, or some other revision control system, for your collaborative work. This would allow each user to check out their own private copy of the files locally, work on these, and then check them into a central repository. Ownership and permissions on the files would no longer be an issue, and you'll gain the benefit of seeing who made what change when (and to roll back changes or fork development into separate branches).
A production checkout of the files could be done on the production system(s) while changes are made on the users' local machines. A new production copy would be checked out when testing shows that it works as expected (whatever it is you're doing).