1

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

Derek Carlisle
  • 485
  • 10
  • 27
  • I would suggest having a local LAMP on each machine. And you could use something better than PHP instead, like http://opalang.org/ or http://ocsigen.org/ – Basile Starynkevitch Sep 02 '12 at 09:55
  • So would the central repo still be on the rackspace server with each user having a clone of that repo on their local machine? – Derek Carlisle Sep 02 '12 at 09:59
  • Yes, with `git` you always have a clone of the central repo. That is the way to use `git`. That private clone is your working source tree. – Basile Starynkevitch Sep 02 '12 at 10:51
  • Thanks. Will the central repo be bare or contain the files? I'd want it to contain the files because that will kind of be the main domain where we will check that everything is working correctly. I tried doing this earlier but got the error refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to 'x.xx.xx.xxx:/var/www/vhosts/test/' – Derek Carlisle Sep 02 '12 at 11:34
  • Then I read that it needs to be a bare domain but I don't think that will work for me. Would each developer need their own branch or would they all be master? – Derek Carlisle Sep 02 '12 at 11:34
  • Anyone got a tutorial that works in the way I need it to? Working locally with a central repository on a remote server which will act as the 'main' domain where we can check that everyones work has been committed and works together? – Derek Carlisle Sep 02 '12 at 12:12
  • initialize a `git` repo on the remote server. USe an `ssh:` URL to clone it. – Basile Starynkevitch Sep 02 '12 at 12:21
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/16152/discussion-between-derek-carlisle-and-basile-starynkevitch) – Derek Carlisle Sep 02 '12 at 12:31
  • Hi, that's what I have done but when I try and push from my clone (on local machine) I get an error I can add and commit fine but when I do git push x.xx.xx.xxx:/var/www/vhosts/test/ master I get this error: ! [remote rejected] master -> master (branch is currently checked out) – Derek Carlisle Sep 02 '12 at 12:40

1 Answers1

0

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.

bokan
  • 3,601
  • 2
  • 23
  • 38
  • OK thanks. So in that case I wouldn't need the individual directories on the server then would I? I could just have the central one on there which will contain the central repository then clone this into each developers local machine. – Derek Carlisle Sep 02 '12 at 10:08
  • Exaclty, you don't need to manage personal folders on the server. Central repo on a server and each user clone it / commit as they want. – bokan Sep 02 '12 at 10:10
  • OK that makes sense. I'm just doing a quick test now. I've setup the central repo in /var/www/vhosts/test/ on the server using git init, created a test index.php file, added and committed it. I've then cloned this on my local machine using git clone x.xx.xx.xxx:/var/www/vhosts/test/ and I have the index.php file. So far so good. I now want to create a new file locally called index2.php. I've done git add index2.php and git commit -m "git local test file". How do I then update the central repository on the server to get this new file? Do I pull it from central using git pull? – Derek Carlisle Sep 02 '12 at 10:17
  • To be honest I do not use the git command line. I advise you to use Tortoise Git. I think the command to put on central repo is #> git push origin master. – bokan Sep 02 '12 at 10:26
  • Ahh ok. I want to try and learn it from the command line. I had already tried git push origin master but get the following error: – Derek Carlisle Sep 02 '12 at 10:28
  • remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to 'x.xx.xx.xxx:/var/www/vhosts/test/' – Derek Carlisle Sep 02 '12 at 10:30
  • Start by reading this http://ftp.newartisans.com/pub/git.from.bottom.up.pdf The biggest problem in Git for me is the inconsistent vocabulary that appears in error message, some things have 3 different names. – bokan Sep 02 '12 at 10:33
  • Do I want to make the central repo on the server a bare repo? See the answer with 429 likes - http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked – Derek Carlisle Sep 02 '12 at 10:42
  • However, am I right in thinking a bare repo doesn't contain any files? Therefore, how am I supposed to view the "central" site to see the changes? Should I be using branches for each developer so they're not all using master? – Derek Carlisle Sep 02 '12 at 10:45
  • 1
    Please avoid starting a disscussion here. You should first start by deleting what you know about source code management. Git is completely different from SVN. Take your time, read the documentation I sent you about Git internals. Once you understand what it does everything will looks simple. – bokan Sep 02 '12 at 15:07