How To Use A Local Repo As A Git Remote

Allure Web Solutions Code Snippet

This article is about how to create and use a local git repo as a remote. The use case I’m using this for is for secure SSL certificate storage. We don’t want to store SSL certificates on a vendor site such as gitlab. But we do need the certs available for our Ansible workflow to deploy them and we want to track them. So the repos sit on a secure server NFS share that’s only accessible by the Ansible script.

# create repo (this will be the remote)
mkdir repo.git
cd repo.git

# initiate bare repo
git --bare init

# create master folder -- repeat this for other branches
cd ../
mkdir master
git clone ../repo.git .
git checkout -b master
git touch
git add -A
git commit -a -m "initial commit"
git push -u origin master

You remote URL would beĀ PATH_TO_REPO/repo.git. You would be able to clone the repo anywhere locally by running git clone PATH_TO_REPO/repo.git. If the repo.git directory is mounded to an NFS share, then you would be able to access it by the URL of the NFS share.

Mike Doubintchik

Author Mike Doubintchik

More posts by Mike Doubintchik

Leave a Reply