Migrate all branches and tags to bitbucket/github/gitlab/other remote endpoint
To have a real world scenario think about the task to migrate from an existing private gitweb repository to bitbucket, with all tags and branches.
The solution simple und just needs some time if the repository is a bigger one.
First, you have to create an empty and new repository at bitbucket.
cd <path you want to do this action>
#the next step is just for safety reasons
mkdir <repository_name>
git clone --mirror git@<your host>:<repository_name>.git .
git push --mirror git@bitbucket.org:<user_name>/<repository_name>
See how easy it is? Why not write a simple bash script?
#!/bin/bash
####
# @link https://artodeto.bazzline.net/archives/19519-Migrate-all-branches-and-tags-to-bitbucketgithubgitlabother-remote-endpoint.html
# @since 2017-11-06
# @author stev leibelt <artodeto@bazzline.net>
####
if [[ $# -lt 2 ]];
then
echo ":: Invalid arguments provided."
echo " <command> \"<source repository url>\" \"<destination repository url>\""
exit 1;
fi
DESTINATION_REPOSITORY_PATH="${2}"
SOURCE_REPOSITORY_PATH="${1}"
TEMPORARY_DIRECTORY="migrate_git_branch"
echo ":: Creating temporary directory."
mkdir "${TEMPORARY_DIRECTORY}"
cd "${TEMPORARY_DIRECTORY}"
echo ":: Cloning from source repository.".
git clone --mirror "${SOURCE_REPOSITORY_PATH}" .
echo ":: Pushing to destination repository."
git push --mirror "${DESTINATION_REPOSITORY_PATH}"
echo ":: You have to remove the following temporary directory if you want to."
echo " "$(pwd)
Trackbacks
The author does not allow comments to this entry
Comments
Display comments as Linear | Threaded