If you did:
sudo chown -R www-data:user1 /home/user1/public_html/
You gave ownership to the user www-data and the group user1.
sudo chmod g+s /home/user1/public_html/
You set the group ID on execution on this folder, I have never seen this done before and I have no idea why one would do this... It's usually used on binaries. You are messing things up with this. Unless you find a valid reason for doing it, reverse that:
sudo chmod g-s /home/user1/public_html/
And set read/write permissions fore both the user1 (which belongs to the group user1) and www-data.
sudo chmod -R 770 /home/user1/public_html
And now you have everyfile writable and readable by www-data and all users in the user1 group (which I assume only user1 is part of, double check it).
This is dirty since you may want some files to be writable only by the user. As a developer, it's not uncommon to "upload" files on the server instead of just editing them, this solves the right management issues by outsourcing it to a secure program as sftp/scp. You could even try to use a SCM.