Migrating commits from upstream to here - openstax/cnx-db GitHub Wiki
Why?
Because we want to preserve the commit history of logic being moved from one repo to another.
Instructions
This is what I did to get changes from Connexions/cnx-archive and Connexions/cnx-publishing:
-
Change directory to where you have cnx-db checked out:
cd cnx-db
-
Clone cnx-archive inside cnx-db:
git clone [email protected]:Connexions/cnx-archive.git cd cnx-archive git remote rm origin # so we don't accidentally push our changes to github
-
Filter out all the files except the sql directory:
git filter-branch --subdirectory-filter cnxarchive/sql/ -- --all HEAD
-
Create the cnx-db directory structure within cnx-archive:
mkdir -p cnxdb/migrations cnxdb/archive-sql touch cnxdb/migrations/.gitkeep cnxdb/archive-sql/.gitkeep git add cnxdb/migrations cnxdb/archive-sql git commit -a -m 'Add cnxdb directory structure'
-
Move the "Add cnxdb directory structure" commit to before the commits you want to cherry pick, for example:
git rebase -i 49c510b^
-
Move files in the commits to the new cnxdb directories:
git filter-branch -f --tree-filter 'test -d cnxdb/migrations && mv migrations/* cnxdb/migrations; test -d cnxdb/archive-sql && mv * cnxdb/archive-sql || echo -n' HEAD
-
Go back to cnx-db and add cnx-archive as a remote:
cd .. git remote add cnxarchive ./cnx-archive git remote update -p
-
Cherry pick the commits you want into cnx-db:
git cherry-pick 49c510b^..cnxarchive/master