Private GIT repositories for small or private projects.
Dec 07, 2025
I’m writing this post mainly for my own future reference, as a relaxing exercise after a very active weekend, just documenting how to create local Git repositories for quick, portable version control. It turned out to be a super handy trick, so I decided to write it up for future reference—and for anyone else who might find it useful!.
Why Use an External Hard Disk for Git?
Sometimes you want your Git repository to be stored outside your own computer, for backup, portability, or to work across multiple machines. By putting your Git repo on an external drive, you can plug it into any computer, clone it locally, and use all the usual Git commands (pull, push, branch, etc.) just like you would with GitHub or any remote server.
This article describes a method intended for temporary use or small projects only. There is no access control or protection against third-party access—anyone with physical or network access to the external disk can read or modify your repository. Do not use this approach for sensitive or critical data. Feedback and suggestions are welcome!
Step 1 - Prepare Your External Hard Disk
Plug in your external hard disk. On Linux, it will usually mount under /media/<your-username>/<disk-name>/. You can check this with:
lsblk
or just look in your file manager.
Suppose your disk is mounted at /media/my-username/risk-management-hd.
Step 2 - Create a Bare Git Repository on the External Disk
Navigate to your external disk and create a new directory for your repository. The convention is to use a .git suffix and make it a bare repository (which means it doesn’t have a working directory—perfect for sharing and syncing):
cd /media/my-username/risk-management-hd
mkdir algo-trading-risk-management.git
cd algo-trading-risk-management.git
git init --bare
You now have a remote-style repository on your external disk!
Step 3 - Clone the Repository Locally
On your main computer (or any computer you want to work from), clone the repository from the external disk:
git clone /media/my-username/risk-management-hd/algo-trading-risk-management.git
This creates a local working copy. You can now add files, commit, branch, etc.
Step 4 - Work as Usual (and Push/Pull)
Do your work in the local clone. When you want to save your changes to the external disk, just push:
git add .
git commit -m "My changes"
git push origin main
Or pull updates if you’ve worked from another machine:
git pull origin main
Step 5: Use It on Any Computer
Whenever you want to work on another computer:
- Plug in the external disk.
- Clone the repo (as above) if it’s your first time, or just
git pullif you already have a clone. - Work as usual!
Tips & Troubleshooting
- Permissions: Make sure your user has write permissions on the external disk.
- File System: For best compatibility, format the disk as ext4 (Linux) or exFAT (cross-platform, but check for symlink support).
- Safe Removal: Always
syncand safely eject the disk to avoid data loss. - Network Sharing: You can also share the external disk over a local network (e.g., via Samba or NFS) and use the same workflow.
Why Not Just Use GitHub?
Sometimes you want to keep things private, avoid the cloud, or work offline. This method gives you full control and is great for sensitive projects, backups, or when you’re traveling without reliable internet.
Hope this information is useful for you. Any doubt not hesitate reaching me out via LinkedIn, I’ll be really happy to help.