Gitstack git server - push to apply changes - php

(Sorry for the unclear title). This is the scenario. I have a local server and I installed Gitstack in it. I was able to to push and pull to this local git server. This same server runs the webapp that I am working on. My plan is to push commits to this local git server and that change must also reflect to the webapp. So instead of using filezilla to copy files from my machine to serer, I will just push the changes via git. How to do it? Or is it possible?
I tried to look inside the Gitstack's installation folder. I expected to see the actual project's files inside but only git files are there.

Related

Git not recognizing remote using php/exec but fine in bash

I am using a VM (homestead/laravel) to try to create a templated repository.
However although it all seemingly works fine but when it gets to pushing it never seems to recognize the remote.
fatal: No such remote 'origin'
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
The above are the 2 errors I typically get.
I have tried a few commands to set the remote.
git remote add origin https:://url.git - does not add the remote (checked git config)
git remote set-url origin https:://url.git - does not add the remote (checked git config)
git config remote.origin.url https:://url.git - sets url, but still does not work.
These are private repos, and I am using https with the user:pass to handle it since I cannot easily manage ssh keys with this setup (in other words I am forced to use HTTPS in this way).
After trying the commands through php I navigate to the directory in ssh and run the push. Works fine (if I use the third option above). I have used exec and https://github.com/kbjr/Git.php but both end up having the same issue.
Git version is: 2.7.2
PHP version is: 7.1.0
The only thought I have is that technically there is a git repo above the one generated. I am creating the repo in a temp folder in laravel and then generating the "template" before pushing it to a repo I create during the process (github api). Once its all done I delete it locally. However I don't see any errors that could be related to problems caused by "a repo under a repo"
Figured it out.
Ends up if you create a repo using the github API it does not actually create the repository before giving back the success response. So you need to force the script to wait before the push. In this case forcing it to wait 5 seconds (sleep(5);) seems to have resolved it.

git push to var/www/application

My friends and I want to make a website using the CodeIgniter PHP framework. We rent a VPS which runs Cent OS 6.4.
As we developed the website, we met a problem: After user A changed something in var/www/application, A must inform B and C that he has changed something, and B and C must then download the new version and try to find out the difference between the new file and the old file (especially when this file had also been changed by B or C at the same time). We managed to use git to solve this problem. We installed gitolite in the server.
However, we now have another problem: after we push changes, we want to push the file directly into var/www/application, so we can test it directly in browsers.
My questions are,
Is it possible to push directly into var/www/application?
How can I do this?
how can I do this pushing with eclipse. I mean what kind of information should I put in the form below(I can't upload picture)
location
url:
host:
repository path:
user:
password:
It sounds like you're wanting to use Git for deployment. git push is what you use to push to a remote repo, not to some directory somewhere. What you really need is a script that does a git pull, and then possibly a git checkout to fetch the updated code from the repo, and switch to whatever branch you're using for deployment (unless you use master, then you can just stay on master all the time).
Depending on where you host your repo, you can set up a hook so that it will hit a URL on your server when new code is ready to grab.

Creating a safe dev environment

We are a small team developing a Wordpress site. Till now we have been editing the same files online, which inevitably led to mistakes. We thought to use Git / Github to stop stepping on each others tows and manage source code efficiently. However I can not run the site locally on XAMPP as I am getting numerous PHP errors. What would you recommend in this case?
Maybe creating another folder on the server with identical content just for testing? Is it possible then to run Git on the server?
I operate in a team of devs and this is what we do.
Locally each set up our own wordpress install under a seperate vhost and locally modified dns. Get just plain jane wordpress running perfectly.
Create a dev testing site on a live server on the internet (often prefix the real url with dev-www.mysite.com)
Create a GIT repository, and have it auto push-deploy to the dev testing site (we create the folder structure in GIT from wp-content down, and only have custom themes/plugins)
Configure GIT to MANUALLY push changes to the production server (for going live)
On all systems we install the wp-migrate-db-pro plugin. Locally devs only PULL from the shared dev site to their local (which means planning what/when/where you create content).
Copy around the /uploads folder, incase there are a bunch of images/media uploaded.
This works when some of us run Windows/IIS/WordPress, Mac/Apache/WordPress, Linux/Apache/WordPress
As a general idea a deployment process could go like this:
developers push their git changes to the server 'staging' area
either manually or using git's post processing, changes are pushed is needed to a virtual Wordpress web host that acts as test or 'staging' server. This can be password- or geolocation-protected
once it's tested properly, then the code can be moved to production web host files, this can be accomplish with a simple script that goes like: stop web server - backup files - nuke files - move files from staging - start web server

'Desynchronize' a PHP config file with Git

I'm currently working on a PHP site, and am using Git both locally (development) and on the production site (a repo on my web server uses a post-recieve hook to deploy to the web root), the details of which are outlined at toroid.org's 'Using Git to manage a web site' article.
Issue is that I also have a config.php file (of sorts) that I use for connecting to the database that differs between my local development environment (a local install of MySQL with test data) and my remote 'production' web server (which has it's own 'live' database). Whenever I push my changes to the website however the config file goes with it and replaces my 'live' config with settings connecting to the (nonexistent) development one! I then have to manually SSH to my web server and replace the config.php file, kind of defeating the purpose!
Is there any way I can get Git to... kind of 'desynchronize' the config.php file? The 'development' config.php should never get saved to the git repo, and when the production server deploys the PHP scripts etc to the web root directory, it should also leave the existing 'production' config.php file untouched.
Is there any way of doing this with Git? Thanks a million for your suggestions!
TC
First I would remove config.php from the repository, then I would create
a file named ".gitignore" and add the filename "config.php" to it.

What is a good solution for deploying a PHP/MySQL site via FTP?

I am currently working on a web application that uses PHP and MySQL, but I do not have shell access to the server (working on that problem already...). Currently, I have source control with subversion on my local computer and I have a database on the local computer that I make all changes to. Then, once I've tested all the updates on my local computer I deploy the site manually. I use filezilla to upload the updated files and then dump my local database and import it on the deployment server.
Obviously, my current solution is not anywhere near ideal. For one major thing, I need a way to avoid copying my .svn files... Does anyone know what the best solution for this particular setup would be? I've looked into Capistrano a bit and Ant, but both of those look like it would be a problem that I do not have shell access...
I'm using Weex to synchronize a server via FTP. Weex is basically a non-interactive FTP client that automatically uploads and deletes files/directories on the remote server. It can be configured to not upload certain paths (like SVN directories), as well as to keep certain remote paths (like Log directories).
Unfortunately I have no solution at hand to synchronize MySQL databases as well...
Maybe you could log your database changes in "SQL patch scripts" (or use complete dumps), upload those with Weex and call a remote PHP script that executes the SQL patches afterwards.
I use rsync in production but you could do this:
Add a config table into your site to hold what level of DB you are currently at.
During development, store each set of SQL changes into a single file (I use something like delta_X-up.sql). These will stay in your SVN as well. So, for example, if you are at delta_5 and add a table between the current release and the new release, all the SQL needed will be put in delta_6-up.sql
When it comes time to build, export the repo instead of using a checkout. This lets you ignore all the SVN cruft that comes along since you won't need that into production.
Use Weex to push those changes into production (this would be were I would use rsync but you don't have that option). Call a remote script that checks your config DB to see what delta level you are currently at, parse the directory with you delta_x-up.sql files and see if there are any new ones. If there are, read them and run the SQL inside.
You can do a subversion export (rather than checkout) to different directory from your working copy, then it will remove all the .svn stuff for you

Categories