Skip to content

Instantly share code, notes, and snippets.

View josealdaco's full-sized avatar

Jose Arellanes josealdaco

View GitHub Profile
josealdaco / gist:d39290a4665b64bc79f544bbc94b5cae
Created October 12, 2023 20:25 — forked from trongthanh/gist:2779392
How to move a folder from one repo to another and keep its commit history
# source:
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone git://
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter your_dir -- -- all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.