Skip to content

Instantly share code, notes, and snippets.

@AndrewO
Created August 24, 2011 17:48
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 AndrewO/1168665 to your computer and use it in GitHub Desktop.
Save AndrewO/1168665 to your computer and use it in GitHub Desktop.
Some steps to extract a changed vendor'd plugin into a branch off of its main repo
# Following instructions found on http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository/359759#359759
# Clone your project repo (making sure to copy all files, even hard links)
git clone --no-hard-links my_app my_active_shipping
cd my_active_shipping
# In your new repo, extract only the commits related to the vendor'd plugin and move that into the new root
git filter-branch --subdirectory-filter vendor/plugins/active_shipping/ HEAD
git reset --hard
# Clean out all of the other commits
git gc --aggressive
git prune
# Remove the old origin to prevent pushing back to the project's repo (optional, but probably want you want)
git remote rm origin
# In another directory, clone the main gem repository (in this case active_shipping)
git clone https://github.com/Shopify/active_shipping.git
cd active_shipping
# Next, find the commit where the plugin diverged (I happened to know it, but you may need to do some forensics). Check it out and start a new branch.
git checkout 684e2e8
git checkout -b my_changes
# Fetch the other repo as a remote (assuming your changes are in master, pull them in as a branch called tmp)
git fetch ../my_active_shipping +master:tmp
git cherry-pick <the commit before your first>..<your last commit in tmp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment