0

I have cloned a repository from GitHub, created two local branches and made several commits to them. In the meantime I decided to not integrate the features implemented in these branches to the original repository but rather to a new repository.

How can I transfer all commits in these two branches (but not the already existing commits from the original repository) to a new repository?

Thomas Neitmann
  • 2,552
  • 1
  • 16
  • 31
  • It's not exactly clear what You want to do TBH. Could You provide some examples? Do You want to copy all history for those commits or just the commits you have made ? – Dominik Wosiński Mar 24 '20 at 11:34
  • Does this answer your question? [pull/push from multiple remote locations](https://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations) – phd Mar 24 '20 at 13:18
  • https://stackoverflow.com/search?q=%5Bgit%5D+push+multiple+remotes – phd Mar 24 '20 at 13:18

1 Answers1

1

How can I transfer all commits in these two branches (but not the already existing commits from the original repository) to a new repository?

Do you confirm that you want to keep all the commits of these two branches?

If yes, the simplest solution consists in adding a remote in your local repository, the push the two branches at stake to this remote. So, assuming these two branches are named feature-1 and feature-2:

git remote add newrepo git@github.com:…/….git
git push newrepo feature-1:feature-1
git push newrepo feature-2:feature-2
# git remote remove newrepo  # optional
ErikMD
  • 13,377
  • 3
  • 35
  • 71