3

I have a project on Github and I started a slightly different version of it on another branch.

I want now to separate that branch into a separate project, which could be synchronized with the original project, so when I make some changes in the original project, i could also pull them to the new branch (but not the other way round).

What is the best procedure for that?

I could, of course, just copy the branch files into a new folder and initialize a new repo then push it to Github, but I'm sure there's a better way of doing what I want, I just don't know how...

Thank you!

Aerodynamika
  • 7,883
  • 16
  • 78
  • 137
  • [This](http://stackoverflow.com/questions/4414140/git-auto-pull-using-cronjob) might help you what you are looking for. – Deepak Biswal Jun 08 '15 at 12:31
  • Thank you, this is interesting, but my goal is not to automatically keep the branch updated. Rather, I want it to be an independent separate project, which can be still integrated with the original one if the need arises. – Aerodynamika Jun 08 '15 at 12:48
  • github itself doesn't support this, but as branches are just pointers to commits you can do this manually... create a new project, clone your old one locally, rename the branches, push it to the new github remote – Jörn Hees Jun 08 '15 at 12:56

1 Answers1

5

I want now to separate that branch into a separate project, which could be synchronized with the original project, so when I make some changes in the original project, i could also pull them to the new branch (but not the other way round).

  1. Create a new project in GitHub

  2. In your existing project, check out the branch of interest.

    git checkout mybranch
    
  3. Push it into the master branch of your new project:

    git push git@github.com:username/project.git mybranch:master
    

Now the master branch of your new project contains the history of mybranch in your exist project.

To keep the new repository in sync:

  1. Add it as a new "remote" to your existing repository:

    git remote add otherproject git@github.com:username/project.git
    
  2. When you make changes to mybranch, push them to the master branch of otherproject:

    git push otherproject mybranch:master
    
larsks
  • 277,717
  • 41
  • 399
  • 399