Clone your branch to a new git repo and preserves all the commit history

There is a case when you develop a project start with an experiment branch or normally create branch to try different version (ie. mobile or web) but then the branch growing stable or finally find out it should not locate under the same repo anymore where no longer any relationship with the original master branch. So there is a requirement to clone your branch over a new repo but still preserves all the commit history and changes. Here is the solution.

  1. Create a new repo.
  2. Under your working directory (switch to branch)

    git push http://github.com/user/new_repo.git +old_branch:master
    
  3. Done.

source from http://stackoverflow.com/questions/9527999/how-do-i-create-a-new-github-repo-from-a-branch-in-an-existing-repo

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s