COPYING ONE REPOSITORY TO ANOTHER

Asked

Viewed 154 times

-2

Good Afternoon, I am working in a company where we are in a process of change, we had a GIT repository in the internal air here in the company that every night updates MASTER with the repositorio master that is in the client, but due to the new guidelines we should no longer use this company’s repository but directly the client’s repository. My doubt, I have a lot of branch in the repository of my company, and some of them have not yet risen to the customer’s master. I would like to somehow copy all the branchs I have from my company to the client’s repository, in order to keep all the branchhistories.

Imagine I have two links

http://mycompany/git/master http://client/git/master the idea is copies all the branches of my company link to the client link, without copying the master and develop

1 answer

0


GIT is a distributed repository, so you can simply push to any server. So the steps to "migrate" from one server to another can simply be to push to the new server on your own machine.

If Object does not exist locally:

git clone <URL_SERVIDOR_ATUAL>
cd <NOME_DO_REPOSITÓRIO>

Checkout every branch you want to "migrate".

git checkout <NOME_DA_BRANCH>

To go through all the branches you can try something like: (I didn’t test this part!)

for remote in $(git branch -r); do
if [[ "${remote}" != "origin/HEAD" ]]; then
git checkout ${remote:7}
fi
done

Also take the tags if you wish:

git fetch --tags

Swap a origin for the other:

git remote rm origin
git remote add origin <URL_SERVIDOR_NOVO>

Send everything to the new origin:

git push origin --all
git push --tags

Browser other questions tagged

You are not signed in. Login or sign up in order to post.