Re: git setup
On 2023-08-22 03:00 +0000, Russell L. Harris wrote:
> After much searching and reading, I have not discovered how to set up
> a pair of git repositories to work together.
>
> I write articles for publication. I typically spend anywhere from
> several hours to many days on each article. It is frustrating to work
> for an hour or two on a paragraph or a page and then accidentally to
> erase what I have written.
>
> In the past, I have found git to be a very good solution. But now I
> am moving to a new computer, and I an having difficulty replicating
> the previous setup.
>
> My needs are simple. I need two git repositories.
>
> The first is my work space, into which periodically I commit the
> article on which I am working.
>
> The second repository is my backup; it resides on another machine.
> Several times a day, I SSH into the backup machine and pull the
> working repository. It would be nice to be able to push from WORKING
> to BACKUP, eliminating the need to SSH.
Git supports pushing via the ssh protocol, and since you have already
set up the ssh connection, the rest is rather simple.
> I cloned the WORKING repository from the old host, and the WORKING
> repository appears to function correctly. But I do not know how to
> configure the BACKUP repository. I tried the BARE option, but I am not
> able to push from WORKING to BACKUP.
On the backup machine, create a bare repository:
$ mkdir -p /path/to/backup-repo.git
$ cd /path/to/backup-repo.git
$ git init --bare
Then you can push from your work machine:
$ git push --all ssh://[user@]<backup>/path/to/backup-repo.git
$ git push --tags ssh://[user@]<backup>/path/to/backup-repo.git
where "<backup>" is the hostname of your backup machine, and "user" is
your login name there (which you can usually omit). You probably also
want to add the backup repository as a remote, so that you do not have
to write the long URL every time you push.
Cheers,
Sven
Reply to:
- References:
- git setup
- From: "Russell L. Harris" <russell@rlharris.org>