4

I have created 2 Git repositories (Dev and staging) and branches b1, b2 and b3 in each of the repositories. Now how can I merge say b1 of Dev to b2 to Staging? Is there anything that can be automated so that I will save my time? Or any hookup scripts can be written to do this?

asgs
  • 3,928
  • 6
  • 39
  • 54
Chinmay
  • 43
  • 1
  • 4
  • Maybe the thread of this question can help: http://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories – paulroho Sep 24 '14 at 11:11

1 Answers1

4

You need to add a new remote in the Staging repository to point to Dev

git remote add dev /path/to/repo.git

Fetch all from the dev remote.

git fetch dev

Make sure you are on B2 of Staging. Merge Dev/b1 into Staging b2

git checkout B2
git merge dev/b1
Bartlomiej Lewandowski
  • 10,771
  • 14
  • 44
  • 75
  • Thanks a lot! that really helped. Going ahead, i believe the same thing can be done from my instance to Amazon hosting server where i have Git installed, i.e., to push the code from my staging to production git of Amazon hosted server. Correct me if i am wrong. Also if you can help me in writing a script where I can write those series of commands you have explained so that it saves my time in writing the same commands again and again. – Chinmay Sep 25 '14 at 08:44
  • If the answer answered your question, mark it as such. First try to do this alone, if you have any questions you can ask another question on so, I will gladly help – Bartlomiej Lewandowski Sep 25 '14 at 09:18
  • This is first time for me, so was not aware, my bad. done it though, thanks again ! – Chinmay Sep 25 '14 at 11:53