Git is a fantastic distributed revision control system for source code and other text-based projects. At PageKite, we use it for everything...
Although most projects use centralized source repositories like GitHub to publish and share
git trees, that is not actually necessary, because
git knows how to speak HTTP directly. Any live
git repository can be
pulled if it is made visible to the web - including the working tree on your workstation or laptop.
PageKite of course makes it very easy to put anything on the web...
What follows is a complete "hello world" example. Feel free to go through the steps and try them yourself! This should work on any machine with an active Internet connection. No static IP required.
First, we create the repository:
$ mkdir project $ cd project $ git init Initialized empty Git repository in ...
Then we add a file:
$ echo hello world > hello.txt $ git add hello.txt $ git commit -m 'Initial import' [master (root-commit) 9a2639a] Initial import 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 hello.txt
This command is the one that prepares the
.git folder for remote access over the web. You need to re-run this command any time you want to make the changes you have committed visible to others:
$ git update-server-info
That's all for
git. Obviously you only really need that last command if you already have some code you would like to share...
Next we will add the repository to our
pagekite.py configuration, so it becomes visible to the web whenever we run the program. Note that this example assumes you have already downloaded
pagekite.py and created a pagekite.net account named foo.pagekite.me - please edit the examples to match your actual account details.
First we create and register a kite (domain) for the project. Let's use
pagekite.py's built-in HTTP server and protect the repo with a user-name and password:
$ pagekite.py --add . project-foo.pagekite.me +password/gituser=awesome ...
Note the ".", which represents the current working directory. If you are in some other directory, simply replace the dot with the full path to the repo you want to share.
Next, we start
pagekite.py and leave it running. For this demo we only want to expose this particular project, so we specify the name of the site on the command line:
$ pagekite.py project-foo.pagekite.me ...
Finally, in another terminal (or on another machine), we test it:
$ git clone https://email@example.com/.git Cloning into firstname.lastname@example.org... Password: ... $ cat hello.txt hello world
A clone of the repository should have been created, named
git pull at any time to bring it back into sync with the original.
From the point of view of the person publishing the code, with this set up the command
git update-server-info takes the place of
git push - you run that command whenever you want to make recent changes visible to the world.
Note that the built-in
pagekite.py HTTP server is not particularly fast or efficient, so if you plan to do this on a regular basis, it may be better to make your project trees visible to Apache, Nginx or some other web server and configure your system for always-on operation.
But for quick demos or one-off private pull requests, the built-in server may be just the thing...
Please also keep in mind that your working tree will be fully accessible from the web - so be sure to take whatever steps you feel necessary for security. You might also want to add an
index.html file to the project, as a friendly welcome for folks who visit using a normal web browser.