Mirroring PWSLab Repositories to GitHub, Bitbucket and GitLab or any Git repositories

Mirroring PWSLab Repositories to GitHub, Bitbucket and GitLab or any Git repositories

Introduction

Repository mirroring allows for mirroring of repositories to external sources. It can be used to mirror branches, tags, and commits between repositories. A repository mirror at PWSLab will be updated automatically. You can also manually trigger an update at most once every 5 minutes. 
Entire essential history of commits, tags, and branches will be available as it is in the PWSLab repository, just like the same if you have actually committed your changes to the Mirrored repository. 

Use cases

  1. Automatically updating a repository managed by PWSLab with your customer's repository on GitHub or Bitbucket.
  2. Keeping an extra backup of repositories on PWSLab with external services like GitHub/Bitbucket/GitLab or internally in PWSLab as well. 
  3. Mirror only protected - master branches to an external repo which may be used for archiving or releases.

Overview

When the mirror repository is updated, all new branches, tags, and commits will be visible in the project's activity feed. Users with at least developer access to the PWSLab project can also force an immediate update, unless:
  1. The mirror is already being updated.
  2. 5 minutes haven't elapsed since its last update.

Pushing to a remote repository

Requirements: 

  1. Create a New project if not already exists in PWSLab.
  2. The repository must be accessible over http://, https://, ssh:// and git://.
  3. This user will be the author of all events in the activity feed that are the result of an update, like new branches being created or new commits being pushed to existing branches.
Note: If already code is available in the external GitHub/Bitbucket/GitLab repository, make sure you first import all your commits, branches, files and changes into PWSLab using git_by_url functionality. 

For an existing project in PWSLab, general instructions to setup push mirroring are as follows:
  1. Navigate to your project’s Settings > Repository and expand the Mirroring repositories section.
  2. Enter a repository URL in this format https://username@company.pwslab.net/group/project.git.
  3. Use the default authentication method as Password from the Authentication method dropdown, if necessary.
  4. Check the Only mirror protected branches box, if necessary.
  5. Click the Mirror repository button to save the configuration.



When push mirroring is enabled, only push commits directly to the PWSLab repository to prevent the mirror diverging. All changes will end up in the mirrored repository whenever:
  • Commits are pushed to PWSLab.
  • A forced update is initiated.

In the case of a diverged branch, you will see an error indicated at the Mirroring repositories section.

All the changes, tags, branches and files pushed to PWSLab repository are automatically pushed to the remote mirror in the background at least: 
  • Within five minutes of being received.
  • Within one minute if Only mirror protected branches is enabled.

Mirroring to a GitHub repository

To set up a mirror from PWSLab to GitHub, you need to follow these steps:

  1. Create a GitHub personal access token with the repo box checked in the access permissions.
  2. Fill in the Git repository URL field using this format: https://<your_github_username>@github.com/<your_github_group>/<your_github_project>.git.
  3. Fill in Password field with your GitHub personal access token.
  4. Click the Mirror repository button.


The mirrored repository will be listed. For example, https://*****:*****@github.com/<your_github_group>/<your_github_project>.gitThe repository will push soon. 

Mirroring to a Bitbucket repository

To set up a mirror from PWSLab to Bitbucket, you need to follow these steps:

  1. Create a new project on Bitbucket if not already exists
  2. Fill in the Git repository URL field using this format: https://<your_bitbucket_username>@bitbucket.org/<your_bitbucket_group>/<your_bitbucket_project>.git.
  3. Fill in Password field with your Bitbucket account password.
  4. Click the Mirror repository button.

Mirroring to a GitLab repository

To set up a mirror from PWSLab to GitLab, you need to follow these steps:

  1. Create a new project on GitLab if not already exists
  2. Fill in the Git repository URL field using this format: https://<your_gitlab_username>@gitlab.com/<your_gitlab_group>/<your_gitlab_project>.git.
  3. Fill in Password field with your GitLab account password.
  4. Click the Mirror repository button.

Forcing an Update

While mirrors are scheduled to update automatically, you can always force an update by using the update button which is available on the Mirroring repositories section of the Repository Settings page. To force a push, click the Update button as below






Troubleshooting

Should an error occur during a push, PWSLab will display an “Error” highlight for that repository. Details on the error can then be seen by hovering over the highlight text.
13:Received RST_STREAM with error code 2 with GitHub
If you receive an “13:Received RST_STREAM with error code 2” while mirroring to a GitHub repository, your GitHub settings might be set to block pushes that expose your email address used in commits. 
Either set your email address on GitHub to be public, or disable the Block command line pushes that expose my email setting.


Have more questions? Please email us at support@peerxp.com
Also, let us know if the article is helpful!

    • Related Articles

    • How to duplicate a Git repository? Repository mirroring simplified.

      To duplicate a repository without forking it, you can run a special clone command, then mirror-push to the new repository. Before you can duplicate a repository and push to your new copy, or mirror, of the repository, you must create the new ...
    • Simple steps to synchronise a Remote Fork in a Git repository

      Introduction When you collaborate in any upstream project (like an open-source project) it is likely to be asked to make a fork of the main repository. A fork is a copy of the project in your Git account. This duplicate allows you to freely ...
    • List of PWSLab CI/CD Environment Variables

      Introduction This document enlists a set of pre-defined environment variables accepted by PWSLab CI/CD for the local environment of the Runner. These can be referenced directly in the .pwslab.yml file or via the Project's Settings > CI/CD > ...
    • How To Change Git Remote URL?

      Introduction Git remote is a pointer that refers to another copy of the repository that is usually hosted on a remote server. In some situations, like when the remote repository is migrated to another host, you need to change the remote’s URL. This ...
    • PWSLab Git Workshop - Useful commands and concepts

      Agenda A brief history of Git. PWSLab walkthrough. Configure your environment. Workshop. Git Introduction Visit: https://git-scm.com/about Distributed version control. It does not rely on a connection to a central server. Many copies of the complete ...