Skip to content

Move a folder from one repo to another

Bhargava Sana edited this page Jun 21, 2018 · 5 revisions

These are steps for moving dora from under warehouse repo to its own repo fasttrips-dora.

  1. Clone the source repo at a new location say C:\temp, disconnect remote origin (to be safe), and filter only the folder we need (in this case dora).
C:\temp> git clone https://github.com/sfcta/warehouse
C:\temp> cd warehouse
C:\temp> git remote rm origin
C:\temp\warehouse> git filter-branch --subdirectory-filter dora -- --all
  1. Clone the destination repo also in C:\temp and change directory into it.
C:\temp> git clone https://github.com/sfcta/fasttrips-dora
C:\temp> cd fasttrips-dora
  1. Add source repo as a remote to destination repo, pull it in, and remove the newly added remote souce repo.
C:\temp\fasttrips-dora> git remote add warehouse ../warehouse/
C:\temp\fasttrips-dora> git pull warehouse master --allow-unrelated-histories
C:\temp\fasttrips-dora> git remote rm warehouse
  1. Pull from remote origin and push the transferred and merged code to remote origin.
C:\temp\fasttrips-dora> git pull
C:\temp\fasttrips-dora> git push
Clone this wiki locally