GIT create repositories on Linux Servers

Put an existing repo on a server (personal use):

1. Make special clone:

git clone --bare /LOCAL/PATH/project.git

2. Put clone on server:

 scp -r project.git USER@example.com:/REMOTE/PATH/

3. Test your setup:

 git clone ssh://USER@example.com/REMOTE/PATH/project.git

Shared repo from scratch

To share any git repo on a server you need to make sure of two things:

  1. Have the correct permissions. All objects in the repository must be read.write.
  2. And the repo objects must be owned by the “relative” group. All the people collaborating should be in the “relative” group. Go here and here for more information.

Make sure that git knows that you are sharing. Look at the –shared option for git-init. Since creating a shared git repository requires you to modify permissions on the server, you should create it from within the server. These are the steps you should follow for an empty repository.

1. ssh into server and make the git directory in the path of your choice.

ssh USER@example.com
cd /REMOTE/PATH/
mkdir project.git

2. Change the permissions to allow collaboration:

chown USER:GROUP project.git

* USER is your user.

* GROUP is the group where all your collaborators are.

3. Initialize a special bare shared git repository.

cd procject.git
git init --bare --shared=0660

* This will create a repository that lets everyone in the group GROUP push and pull.

4. Test your repository in your local machine

git clone ssh://USER@example.com/REMOTE/PATH/project.git

* To push the first time you should do a `git push origin master`

Shared from existing repository:

Follow the four previous steps.

1. In your LOCAL repository run

git remote add origin ssh://USER@example.com/REMOTE/PATH/project.git

* You might have to rename the remote to something else than ‘origin’ if you already have a remote.

2. In your LOCAL repository run

git push origin master
Advertisements

About joelgranados

I'm fascinated with how technology and science impact our reality and am drawn to leverage them in order to increase the potential of human activity.
This entry was posted in git and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s