This document describes how to migrate a repository from Stash/Bitbucket Server to GitHub, including:
- Cloning the source repo
- Fetching all refs and tags
- Creating local branches that track remote branches
- Adding a GitHub destination remote
- Applying push/network performance settings
- Migrating Git LFS objects
- Pushing all branches and tags to GitHub
- Git installed
- Network access to:
- Source (Stash):
https://stash.intcx.net/scm/idspa/eclipse_fork_cleanup.git - Destination (GitHub):
https://github.com/intcx/IDSPA.eclipse_fork_cleanup.git
- Source (Stash):
- Permissions:
- Read access to the source repo
- Push access to the destination repo
- (If used) Git LFS installed:
git lfs version
git clone https://stash.intcx.net/scm/idspa/eclipse_fork_cleanup.gitcd eclipse_fork_cleanup/git fetch --all --tagsThis step creates a local branch for every branch under origin/* (excluding origin/HEAD).
for b in $(git for-each-ref --format='%(refname:short)' refs/remotes/origin/ | grep -v -E '^origin/HEAD$'); do
lb="${b#origin/}"
git show-ref --verify --quiet "refs/heads/$lb" || git branch --track "$lb" "$b"
doneAdd a new remote named destination pointing to GitHub:
git remote add destination https://github.com/intcx/IDSPA.eclipse_fork_cleanup.gitThese settings can help avoid timeouts and improve stability for large repositories.
git config --global http.postBuffer 524288000
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999
git config --global core.compression 1
git config --global http.maxRequests 1Note: These are global settings. If you prefer to apply them only to this repo, remove
--globaland run the commands inside the repo.
Install LFS hooks, fetch all LFS objects, and push them to the destination remote:
git lfs install
git lfs fetch --all
git lfs push --all destinationThis pushes every local branch to the destination remote with the same branch name.
for b in $(git for-each-ref --format='%(refname:short)' refs/heads/); do
echo "Pushing branch: $b"
git push destination "$b:$b" || { echo "Failed on $b"; exit 1; }
donegit push destination --tagsAfter completion, confirm:
- All branches exist on GitHub
- All tags exist on GitHub
- Default branch is set correctly in GitHub repository settings
- LFS objects are accessible (if applicable)
Useful commands:
git branch -a
git tag
git remote -v- Ensure you have permission to push to the GitHub repo.
- If GitHub requires a token, use HTTPS with a token or configure a credential helper.
- Keep the Step 6 settings.
- Retry pushing branches individually (Step 8 already pushes one-by-one).
- Re-run:
git lfs fetch --all git lfs push --all destination
- Clone from Stash
- Fetch everything (including tags)
- Create local tracking branches
- Add GitHub as
destinationremote - Tune Git settings for large transfers
- Push LFS objects (if used)
- Push all branches
- Push all tags