Skip to content

Instantly share code, notes, and snippets.

@wlbr
Created January 26, 2012 22:07
Show Gist options
  • Select an option

  • Save wlbr/1685405 to your computer and use it in GitHub Desktop.

Select an option

Save wlbr/1685405 to your computer and use it in GitHub Desktop.
Create a git repo with a central repository server.

##Create a git repo with a central repository server.

Step 1: Connect to server, create a new, empty directory there and initialize an empty repository.

$ ssh server.com
Last login ...
Welcome to server.com!
> mkdir myrepo.git 
> cd myrepo.git
> git --bare init
Initialized empty Git repository in ~/myrepo.git
> exit
Bye!

Step 2: Get into your source directory. If you did not already set up a local git repo you would have to do it now.

> cd myrepo
> git init
Initialized empty Git repository in ~/.git/

Step 3: Add the remote repository as origin repo to to your existing local git repo. Set the local master branch to track the remote branch. Then push to the server:

> git remote add origin [email protected]:/~/myrepo.git
> git push origin master

Finally you can now clone the server repo to a new directory by a simple

> git clone [email protected]:/~/myrepo.git

Further pushs and pulls can be done simply by call git push and git pull (origin master is not needed).

@Ishanmittal1404
Copy link

DONE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment