Quick and Dirty Git Repository

December 29, 2008

Do you have an app you want to keep in version control, put you don't want to put it on Github? Well, you can obviously use git to keep track of your versions, but do you want some way to back it up? Do you have a server you plan to deploy the app to already setup with SSH keys and everything? Assuming you already have git installed on both your machine and the remote machine, here's all you need to do:

  1. Create The Remote Git Repo

    $ ssh yourusername@yourserver.com
    $ mkdir yourproject.git
    $ cd yourproject.git
    $ git --bare init
    
  2. Create The Local Git Repo, If You Haven't Already

    $ git init
    $ git add .
    $ git commit -a "Initial Checkin"
    
  3. Add The Remote Repo

    $ git remote add origin yourusername@yourserver.com:yourproject.git
    
  4. Push To the Remote Repo

    $ git push origin master
    

Now you have a full copy of the repo locally and on the server.

Posted in Technology | Tags Git

Comments

1.

Gotta love git. Sometimes I even do those first steps as a oneliner from my local shell:

ssh remotehost.com "mkdir -p ~/git/project_name.git && cd ~/git/project_name.git && git --bare init"

git is so easy to start with, I almost always `git init` after I make a new folder for code, even if its for some quick experimentation. Helpful when those things grow.

# Posted By Kevin Marsh on Monday, December 29 2008 at 7:53 PM

2.

I use gitosis. http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way is a good place to start.

# Posted By bryanl on Tuesday, December 30 2008 at 8:15 AM

Comments Disabled