Skip to main content

How To Use A Local Repo As A Git Remote

By August 28, 2017Blog, Shell/Terminal, Workflow
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 readme.md
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.

allure

Author allure

More posts by allure

Leave a Reply

Designed by

best down free | web phu nu so | toc dep 2017