Syncrhonize Git project over network, even if you started it locally.
Git is the version control system designed by Linus and used by Google, Facebook, Microsoft, Rails and of course Linux. You can do it too.
You can start tracking your projects locally, without any servers. You can later upload your project to any Linux SSH account and use it from a number of computers. You don’t need sudo nor any new daemons.
Most of the commands below are one-time setup. Normal workflow is just 2 commands.
Prequisites: Command Line Basics, Git basics.
Offline Git
You started using git offline, just to track a single project on your own hard drive. For this, you don’t need any servers – just git.
$ mkdir thello; cd thello $ git init $ echo "TeroKarvinen.com" >> README $ git add . $ git commit -m "Started a readme."
Initialize Bare Repostory on SSH Server
You can create the bare repository as a normal user on any SSH account.
$ ssh tero@example.com server$ mkdir thello.git; cd thello.git/ server$ git init --bare --shared $ exit
Make Local Copy Sync with Server
$ git remote add origin ssh://tero@example.com/home/tero/thello.git $ git push origin master $ git branch --set-upstream master origin/master $ git pull && git push
Normal Workflow
Everything above was just setup, to be done once. When working with your repositories
$ git pull && git push $ echo "http://TeroKarvinen.com" >> README # modify any files in your project $ git add . && git commit $ git pull && git push
Clone to Other Computers
You can keep all your computers syncronized with your repository. For any new computer
$ git clone ssh://tero@example.com/home/tero/thello.git
Then you can follow the normal workflow.
Update: Added ‘git init … –shared’ flag and ‘git push origin master’ after live CD tests with Ubuntu 12.04 LTS Precise.