How do I configure git to create files with the right permissions? - wordpress

I have a git repo that includes submodules for wordpress and a wordpress theme. I am trying to configure this so that I can run "git pull" on the server whenever there is a change, to update the files from the repo. The problem I am having is that after I do a git pull, I end up with a 500 error on the front end and my server logs saying "file is writeable by group". Basically, I need all of the files to have the permissions of "0755" and to stay that way after I update them with git. How can I set this up correctly?

Check out the documentation on filemode. In your repository under .git/, the config file has a section starting with [core]. If you set filemode to FALSE (or zero, I can't quite recall), it will stop git from changing permissions on any of the files. Then, you can just update them to the right permission and leave them alone.
Note that you could run into other permissions errors if you are having git run as a separate user (we do this with a git user who runs automated updates). Just something to be aware of as you set things up.

Related

Git bare repository on remote server

I have a web server with ssh access where I show my customers the preview of their WordPress website. On that Server, I create a git repository for each customer (example: xyz-website.com.git). I run "git init --bare" so I have a repository. Then, I create a hook (post-receive) where I set the git-dir and working-dir. So when I create a Website locally, I can push to that repository and the Website becomes available so the customer can check it.
Problem: When the customer decides to install plugins, there will be new files on the server. My Idea was whenever I need to code something for that website, I just "git pull". Which doesnt work.
Can anyone tell my why and how to solve my problem?
Check whether the wp-content/plugins/ folder is included in your .gitignore file. If it is there, remove it.
For more information, refer this URL: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

Remove file from Git without deleting them locally and remotely

I have a repository for a Wordpress intall that currently has all the Wordpress files included.
I have updated my .gitignore to only include the theme folder but when I push to my staging server it deletes all the files.
I need to keep all the files both locally and on the server, but I want them to stop being tracked and removed from the repository, Ideally with the history still intact.
Thanks in Advance
The server has a copy of the repository, so if you remove anything from the repository it will be removed from the server's repository as well (after you push).
However, you can set git to assume the files are unchanged. This will keep them in the repository, but git will stop detecting new changes to them.

openshift wordpress plugin needs to be granted write access, how do this?

I am trying to install CiviCRM in my openshift wordpress 'gear' And I am getting the following when I attempt to run civicrm's installation wizard:
The user account used by your web-server - 542ddc2950044666c40008d9 -
needs to be granted write access to the following directory in order
to configure the CiviCRM settings file:
//var/lib/openshift/542ddc2950044666c40008d9/app-root/data/plugins/files
Does anyone know if what it is asking is possible?
and then how do I go about setting that?
Thanks!
The plugins/files/civicrm directory is where CiviCRM stores its cached templates, file attachments, premium (thank-you gift) images, and more. It'll need to save stuff there regularly, not just at first.
The best thing to do is to log in through SSH like developercorey recommends and:
cd ~/app-root/plugins
chmod 755 files (changing the permissions so the owner can write and everyone can read/execute)
chown 542ddc2950044666c40008d9:542ddc2950044666c40008d9 files (making the user that the web server runs as ("542ddc2950044666c40008d9" as mentioned in the error message) be the owner of the directory
have the installer check again
SSH into your gear using the rhc ssh command
cd ~/app-root/plugins
ls -lah
Look for the "files" directory and see what the user and the permissions are on that folder, you can change with the "chmod" command to allow it to be written to by the web server, but be careful what you do or you could cause a major headache for yourself (like getting your WP blog hacked). Hopefully the instructions for that plugin include setting the permissions to something reasonable when you are done.

How to prevent git pull from overwriting a file?

I use Git and GitHub to push changes I make on my local web development environment to my GitHub account and from there I pull these updates to my live production site. I am working with WordPress, so what I have done is .gitignore the wp-config.php file as my productions site has its own unique wp-config.php file with its own respective database credentials. As I am git ignoring this file, when I pull to my production site it gives me the following error:
error: Your local changes to the following files would be overwritten by merge:
wp-config.php
Please, commit your changes or stash them before you can merge.
Aborting
How do I prevent this wp-config.php file from being overwritten (more specifically deleted) when I do a git pull?
This is your machine specific config file. For such case its better to use build tool. For you its better to create your custom configuration on a special file my-config.php and include it in wp-config.php. Also ignore my-config.php in .gitignore. Now you'll never see any problem like this.
What you will see is my-config.php file not found error. And write it about in your README.
I do this whole thing with configure, make even the project is in php
If this was not a config file, and you are sure about the changes you can commit first and then execute pull. Other option is stash which is already told in the error message.
Your changes won't be overwritten. That's what the error message is telling you. The pull failed because git doesn't want to overwrite your changes.
To allow the pull to take place and keep your changes, do git stash before pulling. This will save a copy of your changes and allow you to pull without any issue. Then git stash pop after pulling will restore your changes. Note that you may experience a merge conflict if the changes you are pulling to wp-config.php touch the same part of the file as your local changes.
The other side doesn't have the ignore file in effect yet. Once it's there, you won't have this message. Also it's still tracked. So in addition to changing the .ignore file on both sides, you also need to delete it on both sides and from then on it will not get in the way.
Also take a look at octopress if you are going to be using git as part of your blogging routine.

Is it possible to flush all image module directories in Drupal 7?

Is there a way to flush all of the image directories at once? Perhaps using Drush?
Also, from the command line, with drush installed:
drush image-flush
which gives you a drop-down of all catagories. Choose 'all'!
I've done this on my system, but make sure you back it up when you test it out yourself.
Simply delete the styles directory in your files directory. They will re-create as they are loaded.
i.e. from the command line, from your web root, you would run:
$ rm -rf sites/default/files/styles
You may run into permission issues as those files will be owned by the web user. In that case, maybe you could have a form & submit handler in a module delete those files since that would be run by the web user. That is another topic though.

Resources