1

I have a repo-a in github with many folders (f1, f2, f3). I want to create a new repo (repo-b) with f1, with all the branches.

Repo-a
 |_ f1
 |_ f2  ------+ 
 |_ f3        |
              |  Copy folder with branches and history 
Repo-b        |
 |_ f2  <-----+

This is what am i doing, but it only pushes one branch:

  1. clone the original repo

    git clone https://github.com/myuser/repo-a

  2. now remove everything but the folder i need

    git filter-branch --prune-empty --subdirectory-filter f2 -- --all

  3. then i change the remote origin to the new rep

    git remote set-url origin https://github/myuser/repo-b

  4. and finally i push everything

    git push --all origin

As i stated, when i check on repo-b it only contains one branch and not all of them.

Any ideas ??

Thanks.

gipsh
  • 578
  • 1
  • 3
  • 20
  • 1
    https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/ – adrianbanks Jan 08 '16 at 23:00
  • Thanks for the link, but it fails on point 5. (git filter-branch --prune-empty --subdirectory-filter \ YOUR_FOLDER_NAME master). any idea? it says 'bad revision' – gipsh Jan 09 '16 at 22:55

1 Answers1

-1

The answer to a previous question details how to do this. https://stackoverflow.com/a/22907155/3566042

In short, see GitHub's documentation at https://help.github.com/articles/duplicating-a-repository/

To create a duplicate of a repository without forking, you need to run a special clone command against the original repository and mirror-push to the new one.

Otherwise, you can fork the first Github repo.

Community
  • 1
  • 1
Rrrapture
  • 64
  • 1
  • 7