Let’s assume you work on some client project. After a while you realize that the nice small tool you wrote is actually reusable and can/should be shared as opensource.
Now there are a two of possiblities:
- Copy the files and give a shit about the history
- Extract the history from an existing repo.
But how would you extract a history from an existing repo?
Extract history from existing repo.
Step 1: Clone the existing repo into a new one:
git clone existingrepo new_opensource_repo
cd new_opensource_repo
Step 2: Remove every commit beside the ones in the subfolder:
git filter-branch --prune-empty --subdirectory-filter YOUR_FOLDER_NAME master