Last active
August 29, 2015 14:21
-
-
Save andrewseidl/17e68fa2b1e3c651115b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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