(I have seen pull/push from multiple remote locations but my question involves something slightly different, or at least different enough that I can't figure it out.)
I am trying to write a script that will create a (private) repo on GitHub, but I want to also have all of the commit history, etc on another server as a backup in case GitHub ever explodes, gets taken over by space aliens, or is otherwise unavailable. The idea here is that if we wake up some morning and can't use GitHub ever again, I'd like to be able to just point to my server and have it take over as smoothly as possible.
What I Know (or think I know)
I can create the new (private) repo on GitHub very easily. I have that part all figured out using the GitHub API and it seems to work fine. (I thought that would be that hard part, but it was fairly easy.)
I understand about adding this part:
git remote set-url origin --push --add <a remote>
git remote set-url origin --push --add <another remote>
What I Don't Know
The problem is that I can’t seem to figure out how to set up the repo on the non-GitHub server.
I have my user account setup on the remote server, and I can ssh
to it using ssh public key encryption. I can run commands on it just fine, and I can even pull from GitHub using my private GitHub account.
However, I can't figure out what the right commands are in order to setup the initial git repository so that it will accept the changes that I want to push
to it.
I’ve tried running git clone
and git pull
and git init
on the server, but they all resulted in errors when I tried to push
additional changes.
I finally ran git init --bare
which seems to have worked in-as-miuch as no errors are given when I do push
, but none of the “non-git” files from the repo are actually present in the folder on the server, it’s just the git-specific files:
HEAD
branches/
config
description
hooks/
info/
objects/
refs/
so if GitHub were to disappear, I wouldn’t have a copy of the files on my server, which seems to defeat the whole purpose of what I’m trying to do.
I’ve been all over Google and stackoverflow.com looking for solutions, but I must be missing something fundamental here. I only have a basic knowledge of git
(just enough to be dangerous, as the saying goes).
Thanks for your time and attention.
edited to add: Thanks to VonC for the answer below, which clarified what I needed was a bare repo, but with another feature, as he described, to give me access to my files in that repo. I think that's exactly what I needed but didn't know enough to ask for.