Article: „Mirroring“ my open-source Git repos to my Gitea instance

This commit is contained in:
Marcel Kapfer 2020-08-30 01:20:26 +02:00
parent 59c2c55f2e
commit bcc8526faa
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09

View file

@ -1,6 +1,90 @@
#+HUGO_SECTION: blog #+HUGO_SECTION: blog
#+HUGO_BASE_DIR: ../ #+HUGO_BASE_DIR: ../
* DONE „Mirroring“ my open-source Git repos to my Gitea instance :@code:git:
CLOSED: [2020-08-30 Sun 01:17]
:PROPERTIES:
:CREATED: [2020-08-30 Sun 00:32]
:EXPORT_FILE_NAME: gitea-gitlab-clarification.md
:END:
tl;dr: GitLab will still be my primary Git platform for my public
projects/repositories, but these repositories can now also viewed at
my Gitea instance at [[https://git.mmk2410.org][git.mmk2410.org]].
** Additional links appearing to my Gitea instance
You may have noticed that I added a link to a Gitea instance on some
places next to a link to my GitLab account. The reason behind this
is the following.
For years I always had a Git “server” running on my virtual private
server (VPS) for private purposes. There was also a time where I had
all repositories hosted exclusively on a private Phabricator
instance and the only way to interact with them was through it.
After that I moved all my public repositories to GitLab and mirror
them to my GitHub account. I further used the Phabricanntor instance
for private purposes, later switched to a cgit with gitolite
installation and a few months ago I set up a Gitea instance because
I needed something with Git LFS support and Gitea provides that.
Since I like Gitea quite a bit I started moving some (and as of now
any) public repositories to my Gitea instance and mirroring them
Gitlab. I have not made this change public since actually nothing
changes in practice: I still accept issues and merge requests on
GitLab and will keep doing so. In case I myself create issues on my
public repositories I will do it also on GitLab. Actually creating a
account and interacting with my Gitea instance is currently not
possible
So GitLab will still be my primary code hosting platform for public
projects/repositories. At least for now and if this changes I will
inform you in advance.
Since I do not know where this leads in the future, I start linking
to my own Gitea instance.
** Mirroring a repository from Gitea to Gitlab
While the main reason for this post was to inform you about the
reason for the new links to my Gitea instance you may be also
interested in how achieve the mirroring from Gitea to Gitlab.
I setup the sync a few months ago by following a blog post I found.
I did not write down the URL of that post so I searched right now
for the post. I am not entirely sure but I think it was a German
post on Gurkengewuerz called [[https://www.gurkengewuerz.de/gitea-zu-github-mirror/][Gitea zu Github mirror]].
The idea is quite simple:
1. Create a SSH key e.g. with =ssh-keygen -t ed_25519 -b 4096 -f gitea=
2. Add the *public* key to the Gitlab repository
3. Create a post-receive Git hook in the Gitea repository with the
following content.
#+begin_src shell
#!/usr/bin/env bash
downstream_repo="Remote SSH URL"
# if tmp worries you, put it somewhere else!
pkfile="/tmp/gitlab-mirror-ed25519"
if [ ! -e "$pkfile" ]; then # unindented block for heredoc's sake
cat > "$pkfile" << PRIVATEKEY
### ENTER YOUR PRIVATE KEY HERE ###
fi
chmod 400 "$pkfile"
export GIT_SSH_COMMAND="ssh -oStrictHostKeyChecking=no -i \"$pkfile\""
# if you want strict host key checking, just add the host to the known_hosts for
# your Gitea server/user beforehand
git push --mirror "$downstream_repo"
#+end_src
(Hmm. Since there are comments in English maybe I found another
block back then which uses the same idea. If I find it again I will
link it here.)
* DONE Switching my Website to Hugo using ox-hugo :emacs:orgmode:hugo:@web: * DONE Switching my Website to Hugo using ox-hugo :emacs:orgmode:hugo:@web:
CLOSED: [2020-05-15 Fri 18:50] CLOSED: [2020-05-15 Fri 18:50]
:PROPERTIES: :PROPERTIES: