0

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:

  • How can I push development and changes made on Repo A to Repo B considering they will no longer share the same ancestor / code, especially after the first changes has been made?

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.

hsim
  • 2,000
  • 6
  • 33
  • 69
  • Check write access – Shireesha Parampalli May 21 '19 at 13:13
  • why not use branches instead of separate repositories -- this is the reason branches exist. – Hogan May 21 '19 at 13:17
  • @Hogan Well we will have a repository in Azure and another on our local servers, is that manageable? – hsim May 21 '19 at 13:22
  • Why won't you be sharing common ancestors? Like it's policy? It's not like you can't push branches from any remote into another (**you can**, just in case it's not obvious from my wording). – eftshift0 May 21 '19 at 13:56
  • @eftshift0 Well on that case it's my lack of expertise related to git. I do not know how to do this and since we need to have a repo both in Azure and on our local servers for a few months I do not know how to do it. – hsim May 21 '19 at 14:07
  • this is exactly where the "distributed" part of the distributed source control comes in -- you should be able to have it in both places and merge when needed. – Hogan May 21 '19 at 20:10

2 Answers2

1

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.

HRK44
  • 2,382
  • 2
  • 13
  • 30
  • The trouble is that we need to setup a repo in Azure and we already have a whole setup made for deployment in our current sevent. – hsim May 21 '19 at 13:18
  • I don't see where the trouble is, if you correctly setup your remotes, then you can treat them as 'local' repos and do all the git operations between them (merge, pull, push, etc...). – HRK44 May 21 '19 at 13:26
  • Ah ok. Very interesting, I'll see what I can do with that! – hsim May 21 '19 at 13:28
  • When I try to do something like that git shows me an error: Git failed with a fatal error. fatal: refusing to merge unrelated histories – hsim May 21 '19 at 13:58
  • You will need to check the errors one by one, for example https://stackoverflow.com/questions/38255655/trying-to-pull-files-from-my-github-repository-refusing-to-merge-unrelated-his – HRK44 May 21 '19 at 14:13
  • 1
    Your comments and answer pushed me in the right direction, thank you! ^^ – hsim May 21 '19 at 14:32
1

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.

eftshift0
  • 26,375
  • 3
  • 36
  • 60