Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
There are multiple Git services available, but by far the two most popular are GitLab and GitHub. Using both GitLab and GitHub in a project is useful for various reasons, such as leveraging different CI/CD pipelines, maintaining a backup, or collaborating with teams using different platforms. In short, setting up multiple remotes and automating pushes, you can efficiently work with both platforms… or just giving you the option of having everything mirrored in two different services at once, and redundancy is always the way top go.
First, clone your repository or create a new one:
git init
Add both GitLab and GitHub as remotes:
git remote add gitlab <gitlab-repo-url>
git remote add github <github-repo-url>
Verify the remotes:
git remote -v
The output should list both gitlab and github remotes.
To push changes to both remotes:
git push gitlab main
git push github main
To push to both simultaneously, use:
git push --all gitlab
git push --all github
Or, define a group remote:
git remote set-url --add --push origin <gitlab-repo-url>
git remote set-url --add --push origin <github-repo-url>
Then push using:
git push origin main
This sends updates to both repositories at once.
To fetch from both remotes
git fetch --all
To pull from a specific remote:
git pull gitlab main
git pull github main
If changes are made on both GitLab and GitHub, you need to merge them:
git pull gitlab main
git pull github main
git push origin main
If using GitLab CI/CD, keep your .gitlab-ci.yml in the root directory. For GitHub Actions, create a .github/workflows/ directory and place YAML files there. Both systems can coexist as as long as their configurations do not interfere.