"We needed technical guidance and support and thanks to the team at Three Rock we now have streamlined processes and can manage the project with ease."

Steve Sherlock: Managing Director 'Oodles' car hire comparison web site

Today's Tech News

Warning: Creating default object from empty value in /var/www/threerock/modules/mod_newsticker/helper.php on line 50
Microsoft Inks UC Deal With Polycom
Under a multi-year agreement unveiled Monday, Polycom will begin shipping...
IT Earnings Way Up at Job Site Elance
Google App Engine, HTML5, search engine optimization and social media...
Google, Verizon Posit Net Neutrality Accord
The two Internet and communications giants have put aside their...
Tech Stocks Gain Despite HP's Plunge
HP investors had a bad day, but the rest of...
New Federal Data Breach Bill Debuts in Senate
The new bill is getting early support from prominent Democrats...
Setup Git Local and Remote repositories

Here at Three Rock, we like to encourage remote working among our developers. This involves a level of discipline in terms of source control. We use both subversion and Git as our tools of choice but we're finding Git is becoming more the norm. The rationale behind this is the subject of many on-line debates. The purpose of this article is to take a developer through the steps needed to set up a repository oh a local machine, do the same on the dev server (a centrally shared resource) and get the two repositories talking to each other.

Configuring Git project in Three Rock environment

Prerequisites:

A Git server has been set up on a box called bluelight. This box is available to the network as git.threerock.com.

A git user has ben created on the server called 'git'. This user has access to the folder where the git repositories are stored.

The Steps: 

1.On your dev machine create your code project using whatever tools you need.

2.Initialise this working project under the git version control system

$ cd ~/projects/[myprojectname]
$ git init
peter@peter-desktop:~/Projects/rentmanager$ git init
Initialized empty Git repository in /home/peter/Projects/rentmanager/.git/

3.Add whatever work you've done to the repository

$ git add app/
$ git add docs/


4.Check the files you want added have been added

$ git status
# On branch master
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#    new file: app/rentmanager/,
#   

5.Open a SSH session to bluelight – (the central git repository server)

$ sudo mkdir /usr/local/share/gitrepos/[myprojectname].git

6.Obviously substitute your real projectname and don't forget to leave the .git extenstion
7.Initialise the repository under the new folder

$cd /usr/local/share/gitrepos/[myprojectname].git

[peter@bluelight myprojectname.git]$ sudo git init
Initialized empty Git repository in /usr/local/share/gitrepos/myprojectname.git/.git/


8.Change ownership of the repository to the system git user

$cd ..; sudo chown git.git -R /usr/local/share/gitrepos/[myprojectname].git

9.Return back to the local dev machine and add reference to the new 'remote' repository from the base directory of the project.

$ git remote add remote ssh://git at git.threerock.com/usr/local/share/gitrepos/myprojectname].git

10.Here the 'git remote add' part says add a reference to a remote repository. The second 'remote' is the friendly name I want to use when referring to the repository on the git server

11.Now commit the local files to the local repository – Note: Step 3 was only an add, not a commit.  When you commit you'll be prompted (or you can enter it as a-m option) to enter a message to be used as a comment.

peter@peter-desktop:~/Projects/myprojectname$ git commit
Created initial commit 633fd3c: initial checkin of project core and data migration files

12.It's time to test the new remote repository by 'pushing your local repository info up to it. This is done using git push

peter@peter-desktop:~/Projects/myprojectname$ git push –dry-run –all --repo=remote
fatal: 'origin': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly

Didn't quite go to plan – so let's see what's wrong

peter@peter-desktop:~/Projects/myprojectname$ git remote show remote
The authenticity of host 'git.threerock.com (192.168.0.15)' can't be established.
RSA key fingerprint is 5a:ce:6e:a4:78:d5:01:50:36:2b:bb:12:67:e1:be:53.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.threerock.com' (RSA) to the list of known hosts.
git at git.threerock.com's password: 
* remote remote
  URL: ssh://git at git.threerock.com/usr/local/share/gitrepos/myprojectname.git

let's try again

$ git push –dry-run –all –repo=remote
git at git.threerock.com's password: 
To ssh://git at git.threerock.com/usr/local/share/gitrepos/myprojectname.git
[new branch]      master -> master

looks like it will work so remove the dry-run parameter

$ git push –all –repo=remote

</end of article>