Local git repository using –bare

Git at home

Intro

Have you ever wanted to just host your repositories at home instead of handing over everything to some lesser trustworthy third-party site? Then this might be a simple solution for you.

Setup

To create the local hosted git repository.

Markdown
>cd location_for_the_repository
>git init --bare new_local_hosted_repo.git

This will create a folder ending in .git
Now to use it, navigate to where you want to checkout your working directory

Markdown
>cd working_directory

and clone the newly created repository

Markdown
>git clone full_path_to_new_local_hosted_repo.git

The workspace is now ready to use, and you can do all the same things you would normally do, using GitHub, Bitbucket or any other online repository.

A Full example:

Markdown
>mkdir ~/repositories
>cd ~/repositories
>git init --bare best_game_ever.git
>mkdir ~/workDirectory
>cd ~/workDirectory
>git clone ~/repositories/best_game_ever.git
>cd best_game_ever
>touch ./note.txt
>git add *
>git commit -m "initial commit"
>git push

Note: Remember to backup ~/repositories

Leave a Reply

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