Skip to content
Daniel Robbins edited this page Sep 14, 2019 · 13 revisions

To enable the Repository Mirror Plugin for a repository, navigate to the repository's Settings page and select Hooks: https://stash.yourdomain.com/projects/YOUR_PROJECT/repos/YOUR_REPO/settings/hooks

To configure the hook, click the Mirror Hook text (or the pencil icon).

Remote Repository via HTTP(S)

  1. Enter the http(s) url of the remote repository. Do not include the user name. Ex. https://github.com/englishtown/stash-hook-mirror.git
  2. Enter the user name
  3. Enter the password (this will be stored encrypted)
  4. Click the Enable Button

Remote Repository via SSH/GIT/FILE

  1. Enter the url of the remote repository. Ex. git@github.com:englishtown/stash-hook-mirror.git or file:///path/to/repo
  2. Click the Enable Button
  3. Under the user that BitBucket runs other, you may need to add the following to your ~/.ssh/config for github.com to disable host key verification. Another alternative is to perform a successful connection manually (via command-line) to github.com so that ~/.ssh/known_hosts is correctly populated prior to running the hook:
Host github.com
        Hostname github.com
        StrictHostKeyChecking no
        CheckHostIP no

This is a solution to a CommandFailedException due to Host key verification failed.

To add additional remote mirrors, click the Add Mirror button. To remove a remote mirror, click the Remove button next to the mirror url you want removed.

Troubleshooting

Depending on the size of the repository, it can take a couple minutes for the initial mirroring to complete. If the commits do not appear on the remote check the following:

  1. Ensure your stash server has a minimum of Git 1.7.10 installed. Check by running git --version.

  2. Double check the remote url and credentials are correct. You can try manually running the git command from the stash repository directory to confirm the url and credentials are correct. Here is an example with a https remote repository url:

git push --prune https://username:password@github.com/englishtown/stash-hook-mirror.git +refs/heads/*:refs/heads/* +refs/tags/*:refs/tags/*

If using ssh, ensure your private key is installed for the user stash runs under.

  1. You may need to accept the ssh fingerprint of the remote server before you can begin mirroring.

  2. Check the stash logs, errors and warnings should be logged by default. Search for com.englishtown in the logs ($STASH_HOME/logs/). For Bitbucket, check $STASH_HOME/log and atlassian-bitbucket.log or the timed versions of it.

  3. Mirroring to a non-bare remote repository can be achieved following the instructions here.