Search code examples
gitserverclonegit-clone

Git setup. Cloning repositories from live server to local server


I am new to Git and have been trying to get it implemented into my workplace environment as we currently have no VC. I have run through the tutorials online and on the website and have an understanding of how it works, the commands, etc. The only issue I am having is actually getting it implemented onto our every day work cycle and how it would work over our development and live servers.

Our setup is as follows:

We have a local server running in the office where we build and create the projects. At the moment, once these projects are ready, we zip up the project, create a new domain on our live server, then upload the files, extract, change config etc. Git is installed on both the local server and the live server.

Now to implement Git into our workflow, this is how I have imagined the process to be:

  1. A new repository is created on the live server for the new project.
  2. The repository is cloned (or branched?) onto our local server from the live server
  3. Each developer can branch and work on their individual branch on the local server. Branches are committed to the local clone.
  4. Once the site is complete, the repository is pushed to the live server.

Am I correct in thinking the above process is what I need to be doing? We could have this completely wrong and I thought posting a question here may help to give clarity as to how I should be using Git. I can see it's an extremely useful bit of software and want to start using it as soon as possible due to the number of developers we have in the office!

Thanks


Solution

  • I think you should add a couple more steps.

    1. A new repository is created on the live server for the new project.
    2. The repository is cloned onto the local server from the live server.
    3. Each developer in turn clones the repo on the local server to his machine, and works on their individual branch on their local copy.
    4. Changes are committed to the branch on the local clone, and these are pushed onto your local server (the one which is commonly used across all devs) into corresponding branch.
    5. Someone merges the code into the deployed branch on the local server.
    6. Once the site is complete and works on the local server, the deployable branch from the local server repository is pushed to the live server.

    Note that, someone has to take care of merging branches on local server and pushing the deployable branch from the local server machine to the remote server machine in this scheme.

    Also, I would suggest using 2 branches, one testing, and another master. Any branch merges on the local server should first happen into the testing branch, and only when the changes are approved in the testing branch, should they be merged into the master branch. The master branch can be then deployed on remote server.

    Another improvement could be to use a code hosting solution like github/bitbucket/gitlab to maintain the repo, and pull changes on both the local server and remote server from this repo.