Skip to content

Instantly share code, notes, and snippets.

@chrislim1914
Forked from wlbr/gist:1685405
Created January 23, 2019 08:03
Show Gist options
  • Save chrislim1914/fb5625741fc9c52c1c1d5611f4e5589d to your computer and use it in GitHub Desktop.
Save chrislim1914/fb5625741fc9c52c1c1d5611f4e5589d 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 user@server.com:/~/myrepo.git
> git push origin master

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

> git clone user@server.com:/~/myrepo.git

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

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