hsim
hsim

Reputation: 2080

Keep a common repository for 2 remotes on evolving project

We are starting a project that takes our current sitecore 8.2 and update it toward 9.0.1.

We are a big shop, so development must still be ongoing while the migration takes place and work is scheduled on a few months.

I am having troubles figuring out how to manage our source code via git, especially since we are moving from local servers to Azure and are having deployment issues which will be resolved eventually.

Our plan is to have 2 git repositories, one for our local servers (Repo A) and one for our migration project (Repo B). Ideally I would be able to push our changes from Repo A to Repo B but I am having a lot of troubles / questions:

So far I have tried to make small changes on a small project located in a repo (a) and push them to another repo (b), but each time I get the following error:

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I mean, I get the error, but I don't wanna pull the remote branch (b), I only want to push my code in a branch in remote b so that we may be able to merge it with our new code on the project that is being updated. When the project is done we will abandon repo A, but the modifications will still be ongoing on repo B, so the loss should be null, however I am having troubles figuring out this part.

Upvotes: 0

Views: 38

Answers (2)

eftshift0
eftshift0

Reputation: 30212

If you want to share branches between the two repos (if at all possible not from the technical POV, it's perfectly possible technically) then you can do it by having a single local repo with two remotes set up. Say, repo1 and repo2. Say there's a branch repo1/blah you would like to move into repo2:

git checkout -b blah # create local branch blah from repo1/blah
git push repo2 blah

There you go, you copied blah from repo1 into repo2. And you can then work as usual, having separate branches on separate repos (sharing ancestors) and you can merge and push and have fun, business as usual.

Upvotes: 1

HRK44
HRK44

Reputation: 2762

Consider cloning/forking Repo A as Repo B, then occasionally make merges from A to B ? Using remotes git remote add to handle it, it should look like git merge repoA/master repoB/master where repoA points to your local git, and repoB to your Azure git.

Upvotes: 1

Related Questions