Setup Git server in Debian VPS

Setup Git server in Debian VPS

Posted: 9 years ago in  Unix | Miscellaneous |


In article Working with bitbucket, I wrote a short guide how to create, upload and working with Bitbucket. They provide service to manage private repository with zero cost. It is greate with only limit of users working in one repository, that is 5 persons. The question is....can we make our own repositories on our server ?


In article Working with bitbucket, I wrote a short guide how to create, upload and working with Bitbucket. They provide service to manage private repository with zero cost. It is greate with only limit of users working in one repository, that is 5 persons. The question is....can we make our own repositories on our server ?

Yes, having a VPS is good condition for development environment.We can create repositories, of course, it is private on your server. In addition, you can add as many user as you want in a project.

Here are simple steps to make thing done:

On Server:

Create folder as repository:

mkdir myrepo.git

Go into myrepo.git

Init blank git repository

git init --bare

On Local Maching with existing sourcecode or blank project:

Let say myproject is sourcecode folder.

Go into myproject folder and init git repository

git init

If it is blank project, create a file to initialize the project then add files to committing list

git add .
git commit -m 'initial commit'

Add link to connect local repository with repository on server

git remote add origin user@server:/path/to/myrepo.git

Then push the first revision to server

git push origin master

From here, you and other developers can checkout/commit from this repository.

git clone user@server:/path/to/myrepo.git
git add path/to/new/file
git commit -m "message"
git push