<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GitLab on miti99</title><link>https://miti99.com/en/tags/gitlab/</link><description>Recent content in GitLab on miti99</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 16 Nov 2026 17:39:19 +0700</lastBuildDate><atom:link href="https://miti99.com/en/tags/gitlab/index.xml" rel="self" type="application/rss+xml"/><item><title>Mirroring a Repository from GitLab to GitHub</title><link>https://miti99.com/en/post/2025/03/26/</link><pubDate>Wed, 26 Mar 2025 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2025/03/26/</guid><description>&lt;p&gt;You probably already know that when creating a new repository on GitHub, GitHub allows you to &lt;a href="https://github.com/new/import" rel="noopener noreferrer"&gt;import a repository&lt;/a&gt; from another Git host.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2025/03/26/img/1.png" alt=""&gt;&lt;/p&gt;
&lt;p&gt;However, in some situations we want to continue pushing code updates to GitLab while keeping the GitHub repository automatically synced with the latest code. How do we do that? Today I&amp;rsquo;ll walk you through setting it up.&lt;/p&gt;
&lt;p&gt;To set up repository mirroring from GitLab to GitHub, follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First, create a GitHub Personal Access Token:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Go to &lt;code&gt;GitHub Settings&lt;/code&gt; &amp;gt; &lt;code&gt;Developer settings&lt;/code&gt; &amp;gt; &lt;code&gt;Personal access tokens&lt;/code&gt; &amp;gt; &lt;code&gt;Fine-grained tokens&lt;/code&gt;: &lt;a href="https://github.com/settings/personal-access-tokens" rel="noopener noreferrer"&gt;https://github.com/settings/personal-access-tokens&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Click &lt;code&gt;Generate new token&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Give the token a name and select the required permissions:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Expiration&lt;/code&gt;: It&amp;rsquo;s best to set a specific expiration date.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Repository access&lt;/code&gt;: Up to you, though it&amp;rsquo;s best to select &lt;code&gt;Only select repositories&lt;/code&gt; (granting access only to the specific repositories that actually need it). If you&amp;rsquo;re setting this up for many repositories under the same resource owner and don&amp;rsquo;t want the hassle of editing it later, you can consider selecting &lt;code&gt;All repositories&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Permissions&lt;/code&gt;: Under &lt;code&gt;Contents&lt;/code&gt;, select &lt;code&gt;Access: Read and write&lt;/code&gt; to grant read and write access to the repository.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Copy the generated token (note: the token is only shown once)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2025/03/26/img/2.png" alt=""&gt;
&lt;img src="https://miti99.com/post/2025/03/26/img/3.png" alt=""&gt;&lt;/p&gt;
&lt;p&gt;1.1. For an Organization, you&amp;rsquo;ll need a bit of extra setup beforehand:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to the organization&amp;rsquo;s &lt;code&gt;Settings&lt;/code&gt;. For example: &lt;a href="https://github.com/organizations/ngamtheproject/settings/personal-access-tokens" rel="noopener noreferrer"&gt;https://github.com/organizations/ngamtheproject/settings/personal-access-tokens&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Navigate to &lt;code&gt;Personal access tokens&lt;/code&gt;, then the &lt;code&gt;Fine-grained tokens&lt;/code&gt; tab&lt;/li&gt;
&lt;li&gt;Under &lt;code&gt;Fine-grained personal access tokens&lt;/code&gt;, select &lt;code&gt;Allow access via fine-grained personal access tokens&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Under &lt;code&gt;Require approval of fine-grained personal access tokens&lt;/code&gt;, choose whichever option you prefer:
&lt;ul&gt;
&lt;li&gt;If you select &lt;code&gt;Require administrator approval&lt;/code&gt;, any newly created PAT will need admin approval before it works.&lt;/li&gt;
&lt;li&gt;If you select &lt;code&gt;Do not require administrator approval&lt;/code&gt;, no approval step is needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;code&gt;Save&lt;/code&gt; on each section once done.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2025/03/26/img/5.png" alt=""&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;After that, go back and create your PAT as described in step 1.&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Configure mirroring on GitLab:
&lt;ul&gt;
&lt;li&gt;Open your project on GitLab&lt;/li&gt;
&lt;li&gt;Go to &lt;code&gt;Settings&lt;/code&gt; &amp;gt; &lt;code&gt;Repository&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Expand the &lt;code&gt;Mirroring repositories&lt;/code&gt; section. For example: &lt;a href="https://gitlab.com/miti99/demo-gitlab-mirror/-/settings/repository#js-push-remote-settings" rel="noopener noreferrer"&gt;https://gitlab.com/miti99/demo-gitlab-mirror/-/settings/repository#js-push-remote-settings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Click the &lt;code&gt;+&lt;/code&gt; button (&lt;code&gt;Add new&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Fill in the details:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Git repository URL&lt;/code&gt;: &lt;code&gt;https://github.com/GROUP/PROJECT.git&lt;/code&gt;
(Replace GROUP and PROJECT with your GitHub username/organization and repository name. E.g.: &lt;a href="https://github.com/tiennm99/demo-gitlab-mirror.git" rel="noopener noreferrer"&gt;https://github.com/tiennm99/demo-gitlab-mirror.git&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Username&lt;/code&gt;: your GitHub account username&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Password&lt;/code&gt;: the GitHub personal access token created in step 1&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;code&gt;Mirror repository&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src="https://miti99.com/post/2025/03/26/img/4.png" alt=""&gt;&lt;/p&gt;
&lt;ol start="3"&gt;
&lt;li&gt;Check the status:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Once configured, the mirrored repository will be listed with a URL like:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;https://*****:*****@github.com/&amp;lt;your_github_group&amp;gt;/&amp;lt;your_github_project&amp;gt;.git
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To verify that mirroring works, you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Push a new commit to GitLab&lt;/li&gt;
&lt;li&gt;Wait about 5 minutes (or 1 minute if &amp;ldquo;Only mirror protected branches&amp;rdquo; is enabled)&lt;/li&gt;
&lt;li&gt;Check GitHub to see if the commit has been synced&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you want to trigger a sync immediately, click &amp;ldquo;Update now&amp;rdquo; (the retry button)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Notes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The mirror will automatically sync new commits from GitLab to GitHub&lt;/li&gt;
&lt;li&gt;If a branch is merged into the default branch and deleted in the source project, it will also be deleted on the mirror during the next push&lt;/li&gt;
&lt;li&gt;If a branch has unmerged changes, it will be kept&lt;/li&gt;
&lt;li&gt;If a branch diverges, the &amp;ldquo;Mirroring repositories&amp;rdquo; section will display an error&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;References:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://meesvandongen.nl/posts/mirror-gitlab-github" rel="noopener noreferrer"&gt;https://meesvandongen.nl/posts/mirror-gitlab-github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.gitlab.com/user/project/repository/mirror/push/#set-up-a-push-mirror-from-gitlab-to-github" rel="noopener noreferrer"&gt;https://docs.gitlab.com/user/project/repository/mirror/push/#set-up-a-push-mirror-from-gitlab-to-github&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;</description></item></channel></rss>