Create Public Git Repository

Git is a distributed versioning control system for handling projects of all sizes with speed and efficiency.

It is very easy to learn even if you have minimum experience with Linux.

You can use for example GitHub repository for hosting your projects or you can create your own repository on VPS.

And that is what are we going to do now, build our own Git repository.

 

To find out more about Git, go to our tutorial with basic Git operations


1. Install Git

2. Add user for your repository

After we installed git, we need to add group for our git user:

Then add user to group git:

And finally set password for our user:

Enter password for your user and you’re done with this step.

3. Create public Git repository

Go to apache web directory:

And make a new folder for your repository:

Now we need to set some permissions to secure our repository:

4. Initialize Git repository

Go to repository directory:

Type following command to initialize bare git repository in this folder:

You need to run the following command to make repository shared:

5. Test your new repository

Before we begin, you need SSH access to your server.

If you don’t know how to setup SSH access, see our SSH Server tutorial.

You can use any Git tool or some IDE for testing repository.

I will use PHPStorm in this tutorial to test repository (see PHPStorm Installation).

Go to VCS > Checkout from Version Control > Git

For Git Repository URL type:

For Parent Directory type:

Note: Use path for your projects, this is an example

For Directory Name type:

Note: This is example, you can type any name you like for your cloned repository

When you’re finished, the window should look like this:

Git Checkout

After that click on Clone button.

Type password for your gituser you created in Section 2.

Your repository will be cloned if everything went fine.


 

You can now add some files and try to Push to your repository to see if everything is working.

If Push command succeeded, your repository is ready for use.

Happy coding!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *