2

Description: My Professor gave us few tasks. So I created two public repos Task1 and Task2 on github and normally I have done these tasks couple of days before the deadline.

And then he told us that we should have one private repo and there store all tasks and additional gave one more task. So I created new repo FinalVersion on Bitbucket and I cloned all my previous repos there, additionally I have done the newest task and pushed my all previous task and the new one to the brand new repo. And then my professor told us that he will check also our commits which I lose when pushed all staff on bitbucket.

Goal: take all commits history from these two repos Task1 and Task2 and put it at the beginning of FinalVersion

I searched it on google but found only example: sb clone repo 1:1 using -mirror option. I thought that I can copy the final version somewhere and then try use -mirror option on Task1 and Task2 and then do rebease the FinalVersion and put it on the latest master node.

But I think there is some better solution. What do you think?

royki
  • 1,593
  • 3
  • 25
  • 45
laikkk
  • 85
  • 2
  • 6

1 Answers1

2

In your local cloned repo Taks1, you can add a remote to Task2 and fethc from it

cd Task1
git remote add task2 /path/to/local/clone/of/task2
git fetch task2

Assuming you did your work in one branch (master) for each repo, you can import that branch from Task2 in Task1

git checkout -b task2_master task2/master

Then, with the current local repo having the full history of task1 (master branch) and taks2 (task2_master branch), you can push everything to a brand new bare repos on BitBucket.

git remote set-url origin /ur/bitbucket/repo
git push --all origin
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The problem is that I cant create new repo, all staff must be on the same `FinalVersion` repo. So when I try to fallow your advice I got _Updates were rejected because a pushed branch tip is behind its remote counterpart_ – laikkk Nov 29 '14 at 14:07
  • Then simply rename your local branches (http://stackoverflow.com/a/6591218/6309) to names which don't yet exist on the remote repo, and push them. – VonC Nov 29 '14 at 14:08