Hosting Git repositories on your server
This is not obvious for everyone, but you can use your regular Linux servers as a place for managing your git repositories. Below is a step-by-step guide on how to set it up.
Let's go to the server and create a root directory for hosting our git repositories:
By convention, we use
/srv/git
Next, you need to initialize new repository with any name you like:
Output will be like this:
Initialized empty Git repository in /srv/git/my-app/
This is called a bare repo. It's a system git data folder for storing history of changes - just the regular .git folder as in any other git repository.
So now we can connect to this empty repo to push some data. To demonstrate it, I'll just create a folder with a README.md file on my local machine:
Then init local git repo, commit changes, connect to remote and push it:
Replace
root@1.1.1.1with your server's SSH username and IP address
And that's it. Now, if you want to clone this repo into another machine, or use it on the server, just clone it as usual and work with it:
To learn more about Git bare repos you can watch this video or read the official Git documentation.