-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Importing existing repos
Yan Su edited this page Feb 25, 2018
·
1 revision
- You have a working installation of GitBucket and admin access
- You have access to the existing repositories (either on you local filesystem or via remote access)
- We're migrate the
gitbucket
organization on Github toacme
group on local GitBucket installation - Local GitBucket is available at
gitbucket.acme.local
(HTTP and SSH available on default ports) - You have bash, git, httpie, and jq, all of these are available on popular systems like Ubuntu/CentOS/OSX(Homebrew). (TODO: Windows)
- We're going to authenticate via SSH
- We're migrating repository only, no issue/pr/wiki
- Add your ssh pub key to your GitBucket user
- Create the organization on GitBucket manually
- List all repos from existing system via API
- Create and push them to GitBucket (preserving all refs)
Here is a working script for migrating all repos from github.com/gitbucket to a local installation. We're only providing this example as a skeleton for your migration, not a definitive guide for every system out there.
#!/bin/bash
TMP=tmp_repo
repos=`http https://api.github.com/orgs/gitbucket/repos | jq -r '.[].name'`
gb_userpass='root:root'
for repo in `echo $repos`; do
echo "--- Migrating $repo"
rm -rf $TMP
# clone from source
git clone --mirror https://github.com/gitbucket/$repo $TMP
# create the repo on gitbucket
http --auth $gb_userpass POST http://gitbucket.acme.local/api/v3/orgs/acme/repos name=$repo
# push to gitbucket
pushd $TMP
git remote set-url origin ssh://git@gitbucket.acme.local/acme/$repo.git
git push origin --mirror -f
popd && rm -rf $TMP
done