Domanda

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!

È stato utile?

Soluzione

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 :

  1. git init all your projects into your local server, at root of your project (so, not htdocs, but htdocs\<YOURPROJECT>
  2. create repositories on GitHub for each of your projects
  3. 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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top