loading...

Pushing Code From GitLab To GitHub

jcowie profile image JCowie ・1 min read

I need some help,

I like to use GitLab on the web to edit files because the UI is a lot nicer than github, however, Github is more popular, so is there a way that I can edit a file on GitLab then push it to the GitHub repo?

Let me know down below, Thanks!

Discussion

markdown guide
 

Hey there !

I know that you can import your repository from GitLab to GitHub using this button:

import button

If you have another repository and want to push to it, you may want to change the repository URL as said in this answer on SO: git remote set-url origin new.git.url/here

I don't know if this will solve your problem but at least I hope it will help !

 

Yeah Thanks, this works a charm!

 

Great answer! Have switched repo's from host with a new origin url before and worked like a charm, so can recommend this :) However the included option in Github might be even easier.

 

To perform a one-off authorization with GitHub to grant GitLab access your repositories:

Open github.com/settings/tokens/new to create a Personal Access Token. This token will be used to access your repository and push commit statuses to GitHub.

The repo and admin:repo_hook should be enable to allow GitLab access to your project, update commit statuses, and create a web hook to notify GitLab of new commits.

In GitLab create a CI/CD for external repo project and select G

Paste the token into the Personal access token field and click List Repositories. Click Connect to select the repository.

In GitHub, add a .gitlab-ci.yml to configure GitLab CI/CD.

GitLab will:

Import the project.
Enable Pull Mirroring
Enable GitHub project integration
Create a web hook on GitHub to notify GitLab of new commits

 

This also works, thanks for your help!

 

Because of the way git works, you can pull from gitlab using a git client (either git itself on the command line, or one with a GUI) and push to github.

I don't know if that actually covers your situation well enough, but it's at least some way you can make it work.

 
git remote add github <gihub repo>
git push github <branch>