I have all my code/projects as repos in github. I use git a lot, I do have few projects which I cannot push to github at the same time, I want to keep a backup on my External Hard drive, is there any existing software where you can turn your external harddrive into a repo where I can just git push and the code gets pushed to the repo on my harddrive?
This makes it really easy to push when you are working and keep a backup.
Simple put, Git hub locally on a harddrive. Thats it.
If it does not exist, how to get started on this and write my own software ? Give your insights.
Best Answer
GitHub Micro-Server Method
To do this, you will need a public key. Info on generating one can be found all over the internet. Do that now. You'll need it in a sec. You will also need the
openssh-server
package installed.First off, you need to prepare the environment for Git. To do this, you need to make a user.
This user will do all of the Git functions. You're gonna need your public key here. Simply run:
Now, you have SSH and the Git user completely set up. Now, we need to make a Git project. To do this, run these commands (still as Git user):
You must shell in and do the above commands everytime you want to make a new repo. More details later. I promise!
Now you have a working Git server you can connect to! You can do all the fun stuff you like doing with Git now!
You can of course invite other people on your local network to use this Git server, as long as they connect with your local IP instead of
localhost
.Now, one project is most likely not enough for you. Fortunately there's a simple way to add/remove repos. Run the following commands:
Then, just connect to the other Git repo when you need to. It's all just changing variables!
You can also (if you want) have a web interface to Git. Info is available from the GitHub official source.
Source for this guide: git-scm.com -- It is a great place for learning how to start a Git server. Start from 4.4 (linked) and move onwards.
file:///
URI MethodFeh. As @muru pointed out in a comment, Git supports the
file:///
URI. Here is a way to do it with no users, but no more micro-server in case your friends come over to play.As you:
To connect:
I personally like the microserver better. You can move it easier, esp. if you get a VPS.
Final Comments
The SSH server method does not allow you to save to an external hard drive (easily), but the
file:///
method does. Just change the paths!You could, theoretically, make the "git" user's home on the external hard drive, but that might cause more troubles than good.