Git bare repository on remote server - wordpress

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

Related

How can I upload my webapp to Amplify from Gitlab without using a .zip file

I am new to HTML/CSS and I'm trying to use Amplify to host my static site. I can easily use the "manual deploy" option and upload a .zip file.
What is the preferred method of using Gitlab with Amplify so that changes can be easily made?
My goal is to have everything in a repository that's not zipped so I can make constant changes.
You'll want to set up hosting for your website using the Hosting with Amplify Console option, which provides a git-based workflow for building, deploying, and hosting your website direct from source control.
You can trigger this workflow by running amplify add hosting in your project directory. Next, select the Hosting with Amplify Console option. Then, select the Continuous deployment option. This will open a browser window and take you to your amplify-project homepage. Here, click on the Frontend Environments tab, select your repository provider, and click "Connect branch". You will have to follow the steps to authorize Amplify to access your repository. Once your provider is authorized, you should see a dropdown menu with a list of your repositories. Select the appropriate repository and branch and click "Next".
Next, confirm your build settings. Assuming your website resides at the root of your project directory, your build settings should likely look something like the following:
version: 1
frontend:
phases:
# IMPORTANT - Please verify your build commands
build:
commands: []
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: /
files:
- '**/*'
cache:
paths: []
Again, click "Next". On the next screen, choose "Save and Deploy". Assuming all things were configured correctly, Amplify should now clone your repository and deploy it. You can now confirm that the process has executed properly by following the link provided by the CLI. Hereafter, every and anytime you push changes to your website to gitlab, Amplify will re-deploy your website automatically.
See docs for further info!

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.

How to duplicate a repo to a new one without affecting the original repo?

I am new to github and very confused right now...
I successfully started a repo that connected with my localhost Wordpress site.
But now, I would like to clone this site to a remote hosting server, also start a new repo connecting with that remote server.
What I did is, I duplicated my local site folder(just in case any failure happens). And I am trying to create a new repo for this duplicated folder.
But seems, Github still knows this is a duplicate and doesn't allow me to create a brand new repo...
Any ideas? Thank you all~
https://help.github.com/articles/duplicating-a-repository/
This should provide you with the information you need. Github has extensive documentation that is user friendly and easy to read.
Create a new blank repository in Github say name foo. Now add this repo's url as your new origin in your earlier repository using the steps below.
Replace the origin in your .git/config file to foo's url (backup
original config file)
Now do
git push origin <branch-name>
Now restore your config file .

Push content from staging to live in WordPress

What is the best and easiest way to push content from a staging site to a live WordPress site?
I've explored various plugins like Site Push and Push Syndicate but am baffled by what I need to do.
The whole point of this is to add new or update existing content for approval before pushing to the live website.
Can anyone suggest a user friendly plugin or explain in a very simple way on how to do this?
Probably a better way would be to have version control as a middle-man. So you would have a github or a bitbucket account that would have dev, qa, staging and master branches on it. You may not use qa and go dev, staging.
You then have a local repo that is synchronized with the cloud repository. You could merger dev into staging ( or qa ) when ready, test, and when it is ready to move to production merge with your master branch.
At this point you have two options. If using github you could use their service hooks to send a $_POST of your changes to your server. On your server you'd have a php script that would read the post and then update the server's git repository. Your code would automatically be pushed to prodcution when merged into master and pushed to github.
Alternatively, you could have a git repo within the production servers root folder and manually pull the master branch. You would ssh into your server and via the command line use the simple command:
git pull origin master
You would previously have to had to setup the origin alias by issuing this command in the server repo:
git remote add origin
This would manually pull the master code from github / bitbucket to your production server.
You may be able to do the 'hooks' method with bitbucket, I've personally never looked into this.
In summary, using github as a middle-man allows you to simply update your server and roll it back if needed. Doing any other copy method will not easily allow rollbacks.
Regards,
Steve

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

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.

Resources