Janis Lesinskis' Blog

Assorted ramblings

  • All entries
  • About me
  • Projects
  • Economics
  • Misc
  • Software-engineering
  • Sports

Using git without an internet connection


Have you ever been in a situation where you are working on a project with someone in the same room and you want to keep your files in sync? What if you want to avoid sending tarballs or zips back and forward but you don't want to go to the effort of setting up a version control server?

If you just want to get started on the work with minimal time spent on setup then you can use the decentralized nature of git to your advantage.

If you have a external hard drive like a USB key or similar you can do the following:

cd /path/to/usbstick
mkdir code_repo
cd code_repo
git init --bare
cd /path/to/local/code
git remote add usb /path/to/usbstick/code_repo
git push usb --all

This make a bare repository on the USB key. A bare repository is just one that doesn't have a working tree attached to it. All the files that git needs to track content will all be there. You then tell git that the repository named "usb" can be found on the USB drive by using "git remote". Finally you push your files over to the usb key repository.

Now that the repository is set up on the USB key you just need to set up the other computer(s) to pull from there:

cd /path/to/local/code
git remote add usb /path/to/usbstick/code_repo
git fetch usb --all

from there it's just a matter of "git push usb --all" and "git fetch usb --all" to keep everything up to date.

If you want to know more I'd highly recommend reading the material over at https://git-scm.com/book.

Published: Fri 02 May 2014
By Janis Lesinskis
In Software-engineering
Tags: git software-engineering

links

  • JaggedVerge

social

  • My GitHub page
  • LinkedIn

Proudly powered by Pelican, which takes great advantage of Python.