1

I have a repository on github which once I finished I imported it to gitlab with new repository --> import project --> github and finally I selected the project to import Then I updated the project on github but I can't get it to do it on gitlab too Is there a way to pull changes to gitlab from this same repository? Thanks!

2 Answers 2

1

The easy way is to:

  • clone your GitLab project locally
  • add GitHub URL as a remote
  • fetch the GitHub repository
  • push to origin (GitLab)

That supposes:

  • the import process has preserved the SHA1 commit history from the original repository (GitHub) to GitLab
  • you have not modified or added new commits to common branches (common to GitHub and GitLab)

Note: GitLab 15.6 (November 2022) improves the GitHub to GitLab import process with:

Import GitHub branch protection rules

When you import projects from GitHub to GitLab, GitHub branch protection rules that have an equivalent on GitLab are mapped to GitLab branch protection rules or project-wide GitLab settings:

  • GitHub rule Require conversation resolution before merging for the project’s default branch is mapped to the All threads must be resolved GitLab setting.
  • GitHub rule Require a pull request before merging is mapped to the No one option in the Allowed to push list of the branch protection rule.
  • GitHub rule Require a pull request before merging - Require review from Code Owners is mapped to the Code owner approval branch protection rule. Requires GitLab Premium or higher.
  • GitHub rule Require signed commits for the project’s default branch is mapped to the Reject unsigned commits GitLab push rule. Requires GitLab Premium or higher.
  • GitHub rule Allow force pushes - Everyone is mapped to the Allowed to force push branch protection rule.

See Documentation, Issue, Issue, Issue, Issue and Issue.

And, still with GitLab 15.6 (November 2022):

Import pull request assigned reviewers from GitHub

Previously, while importing projects from GitHub to GitLab, reviewers assigned to pull requests in GitHub were not imported as reviewers assigned to merge requests in GitLab.

With this release, assigned reviewers are imported as assigned reviewers in GitLab. The following are out of scope for this release:

  • Review approval status.
  • Reviews requested from teams.

See Documentation and Issue.


And GitLab 15.10 (March 2023) adds:

Import GitHub repository collaborators as GitLab project members

Until now, imported GitHub projects didn’t have their collaborators imported with them.
This meant that no users had any permissions on these projects. As a workaround, group owners would add members before the import.

Now, if a collaborator’s role can be mapped to a GitLab role, GitLab adds the GitHub collaborator to the imported project as a GitLab project member.

See Documentation and Issue.

0

An alternative to the other answer would be to turn on pull mirroring in GitLab so that it automatically updates.

Note: This is a paid feature, but paid features are available on public projects.

Not the answer you're looking for? Browse other questions tagged or ask your own question.