Skip to content

Instantly share code, notes, and snippets.

@so298
Created March 3, 2024 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save so298/0edd52d0c9d045fa2d18c79f4438eb0d to your computer and use it in GitHub Desktop.
Save so298/0edd52d0c9d045fa2d18c79f4438eb0d to your computer and use it in GitHub Desktop.
Fine-grained access tokenを利用してGitLabからGitHubへのミラーを設定する

Fine-grained access tokenを利用してGitLabからGitHubへのミラーを設定する方法

GitHubのfine-grained access tokenとGitLabのミラー機能を利用して、GitLabからGitHubのリポジトリへとミラーを行う方法についての説明

1. GitLab側にミラー元となるリポジトリを用意する

特にすることは無いので省略

2. GitHub側にミラー先となる空リポジトリを用意する

普通に作成

3. Fine-grained access tokenの用意

Fine-grained access tokenの作成ページから新たにtokenを生成する

必要な設定は以下の通り

  • Repository access: "Only select repositories" でミラー先のリポジトリを指定する
  • Repository permissions: "Contents" を "Read and write" にする (commitを許可する)

後で使うので忘れずにコピーする

4. GitLab リポジトリの設定

Settings > Repository > Mirroring repositories から設定できる

  • URLのところには https://user_name@github.com/user_name/project.git を指定する
    • user_name@github.com であることに注意
    • GitHub側のリポジトリのhttpsのURLに対してuser_name@を追加すれば良い
  • Passwordのところには先程コピーしたaccess tokenを貼り付け

以上で設定完了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment