How to move branches between repositories?

MasterChief
MasterChief
Hi Git Gurus! What is the best way to move git branches from one repository to a new one keeping the commit history? [B]Details: [/B]There are a few branches in various repositories at the company for testing. My boss wants to consolidate our testing branches from each of those repositories into an empty newly created test-automation repository. Just wondering what the best way to perform this would be and also keep the history. Thanks

Last updated

MasterChief
MasterChief
Hi orbrey, Thanks for the response. I gave that a try and git gave me a succeeded notification but my repository did not contain the branch I pushed to it. Figured out another way by adding a new remote on my new repository then fetching all the branches I needed across into my new repository then checking these branches out and pushing them up. I have added my steps in case anyone else runs into a similar problem. RepA – Repository you want to copy branches from RepN – New repository to store copied branches. 1. In RepA, type [B]git remote -v[/B] and note the origin fetch URL. Execute the following steps in RepN. 2. Add a new remote URL which points to RepA. Use [B]git remote add [/B] 3. Perform [B]git fetch [/B] 4. Perform a [B]git checkout[/B] <[B]Branch in RepA you want to copy to RepN>[/B] 6. Execute, [B]git remote rm [/B] to remove the remote URL after you've fetched and checked out locally all the branches you want. 7. For each of the new branches from RepA you’ve checked out locally, execute [B]git push -u origin [/B] [B]Note:[/B] For steps 3 and 4, only use the pure branch name and not /. Thanks for the help orbrey!

1-4 of 4

Reply to this discussion

You cannot edit posts or make replies: You should be logged in before you can post.

Post a reply
348 views