GitHub version control on FTP based website? - php

I am currently interacting with my sites via FTP, which can get quite annoying and impossible to manage at times.
Is it possible to use GitHub as a version control system for my PHP based websites which is on a different domain name?
If not, can anyone give me some advice on what tool I should look into using in order to set up version control.

You can create a git repository with all of your code for your website, and host it on Github. Then you can make changes, commit them to your local repository, and push them to Github. Afterwards, when you want to deploy your changes, do a git pull on your Github repository from the remote server.
Git is a distributed version control system. You have local repositories sitting in your local machine (your laptop, desktop, etc.) Github is a remote repository hosting service (sort of like Dropbox). When you want to sync the repo in your computer with the one hosted by Github, you do a pull/push. Then, you can sync the repository hosted by Github with the thrid repository on the server that hosts your website using a push/pull. No ftp is needed.

After a bit of research, found the solution to my question.
http://net.tutsplus.com/tutorials/tools-and-tips/how-to-use-git-with-ftp/

Related

GitHub coding setup

I am new to GitHub. I managed to install GitHub for Windows and created a github repository. I'm a PHP developer and this is my current situation before GitHub.
Currently, all of my work go to C:\xampp\Dropbox\* ("htdocs"). Everything I code is in there with each application under its own subdirectory. Whenever I need to update the production server, I FTP our production server and upload the necessary files. This is good when I am working alone but working with other developers would be hard because we need to know who edited which, when what was edited, etc.
Could you help explain how I can maintain my codes using GitHub? I suppose that I shouldn't make the entire htdocs as a local repository. I access my codes via http://localhost/ when testing it locally. Since I develop web applications using PHP, code changes regularly. We don't compile codes and I was used to simply saving all the files and letting Dropbox save all the versions I made.
It's a bit confusing what to do next since the GitHub for Windows application created local repositories in C:\Users\Admin\Documents\GitHub\test-app folder. Should I edit the code in htdocs and ALSO edit the code in My Documents\GitHub? Then also "push" the update to GitHub AND also update our production server via FTP?
So, to summarize, from the primitive perspective of web development, what steps must be changed so that I can enjoy the benefits of using version control systems such as GitHub?
Thank you!
The global idea is to use a versioning server to push code directly into your production server, bypassing FTP boring method.
You can tell GitHub application to clone your code at Xampp htdocs root, instead cloning it into your documents, if you have already initialized your repositories.
Every project must be a GitHub (or Git, more generally) repository.
So, you have to :
git init all your projects into your local server, at root of your project (so, not htdocs, but htdocs\<YOURPROJECT>
create repositories on GitHub for each of your projects
Follow GitHub instructions to initialize projects, git push on GitHub to finish.
You can do all that with a command line. In my opinion, it's easier.
Your code is on GitHub now. You won't have to edit your code into your documents AND htdocs if you initialize your repos in htdocs.
Next, it could be "fun" to install Git on your production server to grab most recent code from GitHub repository. Without Git, it's a pain in the a** to push code on a production server.
Now, when your local dev server and your production server are in sync, every time you will commit and push on GitHub, you can grab latest copy with a simple git pull on your production server.

GIT - Web Development workflow/deployment

I'm part of a team of 3 (2 developers and 1 designer) who sometimes work in the office and sometimes remotely and I'm looking at a way of using GIT to develop our websites seamlessly. I've got a managed account with Rackspace and have 3 servers setup on the account - development, staging and production.
I'm looking at the best way for our team to develop daily on our websites without having to FTP the files up to the server each time we make any changes. I've used SVN in the past but i'm looking to use Git for version control. The workflow I had in mind for an example website called 'test' was the following:
Development Server would have a directory (called trunk but not sure if it should be called something else?) for each user as well as a central directory. E.g /var/www/test/jbloggs/, /var/www/test/asmith/, /var/www/test/rjohnson/ and /var/www/test/central/trunk/.
The central repository would be installed within /var/www/test/central/trunk/ and then /asmith/, /rjohnson/ and /jbloggs/ would clone the trunk which would mean they would become /var/www/test/asmith/trunk, /var/www/test/rjohnson/trunk/ and /var/www/test/jbloggs/trunk/.
Each user would then have a copy of /trunk/ which will contain all the website files, will all have a subdomain configured i.e jbloggs.test.development, rjohnson.test.development etc and will configure their IDE to automatically SFTP to the server so that they are working directly within their directory the development server. The central directory domain will be test.development. When they come to committing any changes to the central repository they will SSH into the server and commit their changes and when we want to update the central repository we will pull these changes to get the latest version which can then be viewed at test.development.
Is this the right method of doing things or should we all have a local LAMP stack installed (apart from the designer who uses Windows) and have our repositories locally? If so, should the central repo still be on the rackspace server? The developers will be using phpstorm and the designer dreamweaver.
Hope the above makes sense.
Thanks
I strongly advise you to work local and then commit on the shared server. This is what git is made for. Development will be more reactive and easier for everybody. Make sure all dev master git so they can do their internal soup as they want. If one dev destroy the database, the others can keep on working. But you'll also need a convenient way to synch databases so developers work with an up to date local database.
The rest of your chain is ok, you can still have two test step like dev server for dev team and test server for testers. This will make testers working on a more stable version and it will also make you test the upgrade process when you copy changes from dev server to test server. Lot of errors arise because of untested upgrade procedures.
You can updates changes on test and production server either by installing GIT on them or just using a simple script that will ftp changed files. I don't like having git on a production server but this is a personal opinion.

How to use Git in my workflow

I'm trying to learn how to use Git in my daily workflow but I'm slightly confused as to how to make it work for me. As a web developer, the way I work is that I have two VPS' - one as a production and the other as a development server. On the development server, I usually create a webdav that points to the source files (located in /home/public_html/dev.domain.co.uk/) and mount it as a local folder on my mac. This way, I can open (or create) the PHP files in my IDE, do what I need to, save the file and then refresh the test link in my browser.
Now, as I say, I would like to start using Git to keep track of all amends I, and my co-workers, make to projects. So my question is how would I do this - would I create a repository on my development server in the public_html folder? And when I clone the repository on the different machines I work on, would I mount the webdav and clone the repository in there? Ideally I want to set up an online repo that myself and co-workers can access.
Any help and/or advice would be much appreciated.
Thanks :)
I have a similar workflow. I was using my IDE to edit the files over SSH, effectively using the files directly on a development server. What I ended up doing was opening a console over SSH to my dev server, and running git there. I use Bitbucket as a remote, and push/pull from there, keeping all of my changes somewhat centralized. What I need to push to my production server, I pull from Bitbucket, and then flip a symlink so that all files appear updated instantaneously.
Git is a decentralized version control system, meaning that you do not need to have a "shared" repository. However, when collaborating, especially if you do not work closely with your coworkers, it might be attractive to have a central point with an "official" repository.
Now in your case, if you want to continue working in your WebDAV exported folder on your testing machine, it depends on if you share this folder with coworkers or not. If it's your private working space, create your git repository there and work with it however you like.
To setup a central, "official" repository you push you changes to, you have several choices depending on your infrastructure:
Use a 3rd party service like GitHub or BitBucket: This is simple to setup and use, but may require subscription fees if you want to keep your repository private.
Use your development server and setup a clone of your repository in a shared place, either via SSH or WebDAV. This might require more maintenance and you don't get the fancy WebUI of GitHub and the likes.
You might also want to have a look at this article about a branching model for development.
You could use a service like http://bitbucket.org.
it's free and it allows to create private and public repositories.
Once you commit changes, simply push it to the server (they tell you how to do it), then have your partner to clone that repository and pull from it whenever necessary.

Integrated development using subversion for PHP

We are two in a team working on the same project. i am on MAC and the other one is on PC. i have never used SVN before. googling about the SVN gave me basic understanding about svn. and what i understood is there should be subversion installed in client machine (i do not know which client, i assume there are many like versions and cornerstone for mac, tortoise for windows etc. and i require a repository where i will host the centralized version of the application. the client will get the copy of codes or files where they can commit the changes to repository (main application). which can be undone if required. however what i don't understand is, as our PHP code uses database(mysql in my case) how is it managed by SVN client?
lastly i expect my development environment to be implemented the following way.
i want to set up my mac as development server for SVN at the same
time i would like to work in the same machine making use of SVN.
PC should access the repository from MAC and commit the changes.
all the setup should be done and implemented locally via LAN. please correct me if i am wrong on my understanding about the svn and also do guide me about the requirements and resources i need to install in both the machine for me to get going using SVN for my projects.
thank you..
You can use your Mac both for hosting your SVN repository and also use it as the client to checkout your working copy. Have a look at this link (its slightly old but you'll get the gist).
Once you have the SVN repository setup you can enable HTTP access on it so that your partner can checkout the copy and commit changes to it. Have a look here on how to enable HTTP access for your repository.
Most modern day PHP Frameworks use migrations scripts that help in building and maintaining your database schema, if possible use a framework. Have a look at the migrations script of one of the frameworks for inspiration (i.e if you can't use a framework). Migration scripts under the hood fire create table or alter table commands, and all you do is add the migration files to your SVN repository to version control your database schema.
One caveat with hosting the SVN repository on your Mac is that for some reason if its down, your partner gets stuck as code changes can't be committed and new changes can't be checked out. Have a look at this thread for free online private SVN repositories. In case you want to go the paid route GitHub.com is awesome.
I develop on my own and use a repository hosted on http://www.springloops.com. On here I just export the database to a text file and keep historic changes to the database on there. Clearly this is not suitable for a team working together on a project unless you're well coordinated in recording your database changes.
This question looks useful MySQL Version Control - Subversion though it's specific to mysql subversioning - not quite the answer to your broader question.
Each machine should have the relevant Client software, I recommend Tortoise SVN for Windows - it's pretty popular. There is bound to be a similar alternative SVN Client for OSX that you can get your hands on.

How to use Git or Subversion?

I code all by myself, and I have 1 website . but i dont ever use subversion or github. Question is:
How to develop on souce code of my website server and update it when develop complete.
In this case , should use github or subversion.
Truthly , i read and using github then try to create repository but anyone can watch mycode . I dont want that.
I want 1 guide easy for very begin about this.
You can use Git locally. So no need for Github. There is a video serie on www.tekpub.com about Git.
SVN and GIT are two completely different types of code repository patterns. If you using GIT you don't need a central server and can create a repository locally on your machine. I recommend you get familiar with this website just to get a basic overview of what a DVCS is and how it can affect the way you code.
HgInit
The good news is that you aren't familiar with any VCS (I assume) and that means you won't get mixed up when trying to learn GIT coming from SVN.
Assuming you already know the basics of how to commit/push/etc with git, which your answer suggests you do, the problem is that your repo is set to be public and not private. You can change this on the repo's admin page, assuming your github account has enough private repos left (The lowest account level that supports this is USD$7/month iirc). There are other git hosts which you can use for free that provide private repos.
As Roger said, you can use Git locally and do not need a server for that.
For SVN you need a central repository server, that usually does not correspond to your live webserver.
You will need a running Apache server and install SVN as an additional module for it. Once you have a subversion server running, you can then add repositories to it, normally one repository per project.
Usually you would have a local subversion installation on a development server in your local network or even (as you work alone) on your local machine, using a distinct host/port configuration for SVN, e.g. you could use localhost:80 for your development of the live website, and localhost:9999 for your SVN installation. There are several guides for installing SVN on Windows, Linux and MacOS found via google.
Both version control systems require some initial work to get it, but I personally prefer Git over SVN. Check out the Git guide on stackoverflow or the SVN book.
Personally, I find SVN easier to learn and install than GIT (but I guess that depends on person ;) and OS - I'm on windows unfortunately)
That's why I choose some free personal host for that. I tried BeanStalk and XP-Dev. The first one, is cleaner and much more user-friendly... and offer GIT or SVn ! But you got only 1 personal project available for free.
The second one is ugly but quite performant, 2 personal projects but only with SVN for free.

Categories