How to create a new git repository on a server

  1. On your server:
    1. Install git as per the documentation related to your server
    2. Setup the default git user
      1. mkdir -p ~/.ssh && chmod 0700 ~/.ssh
      2. touch ~/.ssh/authorized_keys && chmod 0600 ~/.ssh/authorized_keys
    3. Create the repository
      1. git init –bare ~/theNewGitRepositoryNameComesHere.git
  2. On your client (suppose you already have some code to push to the new repo):
    1. Add your public key to the /home/git/.ssh/authorized_keys file (created above) on the server
    2. git init
    3. git remote add origin git@yourServerNameComesHere.com:/home/git/theNewGitRepositoryNameComesHere.git
    4. git add .
    5. git commit -m ‘Initial commit’
    6. git push -u origin master

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.