Created
April 5, 2014 03:59
-
-
Save kode54/9987343 to your computer and use it in GitHub Desktop.
These scripts can be used to prune a Git repository down to just the contents of the specified subdirectory, and prunes the change history to only the files contained within.
This file contains 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
@echo off | |
setlocal enableextensions enabledelayedexpansion | |
set dir=%1 | |
set dir=!dir:\=/! | |
git remote rm origin | |
git filter-branch --tag-name-filter cat --prune-empty --subdirectory-filter "%dir%" HEAD | |
git reset --hard | |
for /f %%r in ('git for-each-ref --format="%(refname)" refs/original/') do git update-ref -d %%r | |
git reflog expire --expire=now --all | |
git gc --aggressive --prune=now |
This file contains 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
#!/bin/sh | |
git remote rm origin | |
git filter-branch --tag-name-filter cat --prune-empty --subdirectory-filter "$1" HEAD | |
git reset --hard | |
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d | |
git reflog expire --expire=now --all | |
git gc --aggressive --prune=now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment