Skip to content

Instantly share code, notes, and snippets.

@slawekzachcial
Last active June 15, 2018 12:38
Show Gist options
  • Save slawekzachcial/6f31b434aa0ba41d13972cd45a01f39e to your computer and use it in GitHub Desktop.
Save slawekzachcial/6f31b434aa0ba41d13972cd45a01f39e to your computer and use it in GitHub Desktop.
Subversion to GitHub migration steps using GitHub-provided tools.
# SSH to GitHub appliance and go to your working directory where you do migrations
# Type your Subversion username + Enter
read SVN_USER
# type your Subversion password + Enter
read SVN_PASSWORD
# type your GitHub username + Enter
read GIT_USER
# type your GitHub **Personal Access Token** + Enter
read GIT_TOKEN
# Type URL of Subversion repository to migrate
read SVN_REPO_URL
SVN_REPO_NAME="${SVN_REPO_URL##*/}"
GIT_REPO="${SVN_REPO_NAME}.git"
# Import the repository
~/git-import-svn-raw-1.10 --user "${SVN_USER}" --password "${SVN_PASSWORD}" \
"${SVN_REPO_URL}" "${GIT_REPO}"
# Create authors files
sed -e 's/,\(.*\)/,\1@dxc.com,\1/' "${GIT_REPO}/git-import/raw-authors.csv" > "${SVN_REPO_NAME}_authors.csv"
# Check authors file if it has empty values that are visible as "" and fix that.
# Usually surronding lines have the right values so you can copy/replace the faulty line with a good one
# vim "${SVN_REPO_NAME}_authors.csv"
# Rewrite authors file
git-import-rewrite --flavor svn --authors "${SVN_REPO_NAME}_authors.csv" "${GIT_REPO}"
# Deal with LARGE FILES
# Check if repository contains files bigger than 100MB limit
REPOSITORY="${SVN_REPO_URL}" SVN_USERNAME="${SVN_USER}" SVN_PASSWORD="${SVN_PASSWORD}" ~/svn_sizer.sh
# ACTION:
# If repo has any files bigger than limit - request size limit change for that repo
# Do the LFS things
cd "${GIT_REPO}"
git lfs install
git lfs migrate info --everything
# Migrate binary files using their patterns, e.g.
# git lfs migrate import --everything --include='*.war,*.jar,*.lar'
git lfs migrate import --everything --include='<comma-separate list of patterns>'
# List files that are now LFS
git lfs ls-files
# type GitHub repository URL; repository must have been already created!
read GIT_REPO_URL
# Inject creadentials to Git repository URL
GIT_REPO_URL="$(echo "${GIT_REPO_URL}" | sed "s,//,//${GIT_USER}:${GIT_TOKEN}@,")"
git push --mirror --force "${GIT_REPO_URL}"
@slawekzachcial
Copy link
Author

git lfs migrate info was only checking current branch. To check all branches: git lfs migrate info --everything. Gist updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment