26
Feb
09

Quickly setting up a Public Git Repository

Recently, I’ve needed to learn how to administrate a Git repo for a contracting gig. Since I’ve had zero experience with git beyond submitting a documentation patch for buildbot, I decided to put together a test setup. The goal was to have a test public repo on a remote server and pull a copy of that repo it to my local dev machine. I was actually surprised at how quick and easy this was to do.

The following assumes that you are in unix-like environments (linux, osx, cygwin), that you have a remote server and a local dev machine, and that you’re going to use ssh for your access to the remote server.

  1. Install Git on both the remote server and your local development box.

  2. On the remote server, we’re going to setup a public repo. Now if you’re planing to do an import of an existing code base with history, that’s kind of beyond the scope of this doc. If you’ve got some code to just import, clean up any scm metadata files.
  3. In the top level of that code base, do the following:

  4. RemoteServer:~> cd gitrepo/
    RemoteServer:~/gitrepo> git init
    Initialized empty Git repository in /home/jedi/gitrepo/.git/
    RemoteServer:~/gitrepo> git add .
    RemoteServer:~/gitrepo> git commit

  5. When you commit, enter your commit message in your favorite editor and let it do it’s work.

  6. Next, on your development box do the following:

  7. [devhost:~] jedi% git clone ssh://some.remoteserver.com/home/jedi/gitrepo
    gitrepo
    Initialized empty Git repository in /Users/jedi/gitrepo/.git/
    remote: Counting objects: 410, done.
    remote: Compressing objects: 100% (356/356), done.
    remote: Total 410 (delta 46), reused 0 (delta 0)
    Receiving objects: 100% (410/410), 457.06 KiB | 249 KiB/s, done.
    Resolving deltas: 100% (46/46), done.
    [devhost:~] jedi%

You should now have the code in your local directory and can now play with running & managing a public git repo.

However, the setup is quite simple and doesn’t solve all problems when you need to setup a production ready public repo. For further information about getting to production ready, check out the official docs regarding the setup of a public repository. Also helpful will be documentation on setting up ssh keys so that you’re not entering your password each time you do any operation with the remote repository.


Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.