Skip to content

Instantly share code, notes, and snippets.

@andrewseidl
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewseidl/17e68fa2b1e3c651115b to your computer and use it in GitHub Desktop.
Save andrewseidl/17e68fa2b1e3c651115b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# `hub` is GitHub's Hub: hub.github.com
# can be replaced with regular `git`, but must use full repository URLs
function initPaths {
mkdir -p merge && cd merge
hub clone projectchrono/chrono
hub clone projectchrono/chrono-parallel
}
# moves everything in the repo into a new directory, given as the first
# function argument
function gitRenameAll {
git filter-branch --index-filter \
'git ls-files -s | sed "s-\t\"*-&'$1'-" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"
' HEAD
}
# renames all files and merges into the new directory
function renameAndMerge {
pushd $1
gitRenameAll "${2}/"
popd
pushd $NEWREPO
git checkout develop
git remote add -f "${2}" "../${1}"
git merge --no-edit "${2}/develop"
git remote rm "${2}"
popd
}
NEWREPO="chrono"
initPaths
renameAndMerge "chrono-parallel" "src/unit_parallel"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment