Saturday, October 27, 2012

Creating a new git repo on a remote server

Let's say you have some source code and you want to create a new git repo on a remote server, and check it in there. Here's the simple steps to create a new repo and push the code you have written. I assume you have git installed in both places and have done the basics to properly initialize things, e.g., add git users and so on.

First, ssh onto the remote machine (for this example, call it myhost) and then:
  • cd to location you want the repo (in my case, on Mac OS X this is /Volumes/SRV-EXT2)
  • mkdir mynewrepo
  • cd mynewrepo
  • git init --bare
back on the machine where the code exists:
  • cd into source dir
  • git init
  • git add your files (I like to add them individually, "git add ," may pick up unwanted files)
  • git commit
  • git remote add origin gituser@myhost:/Volumes/SRV-EXT2/mynewrepo
  • git push origin master
 That's it.

No comments:

Post a Comment