My problem this week: I wanted to share some work with a colleague. Unfortunately we have not yet setup our caplab environment with git server. Nor did i want to push this particular project to GitHub or Unfuddle. My alternative was a file-based setup:
- Each developer’s machine has it’s own Git repository.
- On my machine I had an extra ‘master’ repository that other developers could push into.
- In the example below the local developer repos is called ‘local’ and the master is called ‘remote’
- The master repository could be on a network drive as well.
Developer’s workflow: Push changes to ‘remote’:
git pull ../remote master #get the latest code from ‘remote’ repository
git push ../remote master #push the recent commits from here to the ‘remote’ folder
Git remote makes it easier
In stead of using a path in “git pull ../remote master”, it’s even easier to add the path just like you would do on GitHub or similar:
git pull origin master # pull from the ‘remote’ directory
git push origin master #push recent commits from here to the ‘remote’ folder
Bonus tip: Using remote git to SSH server
It’s real easy to make a remote backup copy of your Git repository even if you have not set up a git server. Here is an example of how I did it on a server where I have SSH access to:
Setup the repository on the remote server:
Welcome to myserver.com!
$ mkdir project.git && cd project.git/
$ git –bare init
Initialized empty Git repository in /home/jesper/project.git