cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to migrate a repo from Git to another SCP Global account, by holding the history?

manuel_baehr
Explorer
0 Kudos

Hi guys,

I have SAPUI5 apps in the Git Service provided by SAP Cloud Platform in Global Account A and want to migrate the repository to the Git Service of another Global Account B. Addionallty I want to keep the history created in the first Git (commits, timestemps, etc.).

I am using the same User in both accounts.

I couldn't find a way until now, would be nice, if someone could help me.

Kind Regards,

Manuel

Accepted Solutions (0)

Answers (2)

Answers (2)

gregorw
Active Contributor

So here we go with full details:

C:\Users\gwolf\Documents>git clone https://git.hana.ondemand.com/<SubaccountA>/gittest
Cloning into 'gittest'...
remote: Counting objects: 12, done
remote: Finding sources: 100% (12/12)
remote: Total 12 (delta 0), reused 10 (delta 0)
Unpacking objects: 100% (12/12), done.

C:\Users\gwolf\Documents>cd gittest
C:\Users\gwolf\Documents\gittest>git remote add test https://git.hana.ondemand.com/<SubaccountB>/gittest

C:\Users\gwolf\Documents\gittest>git remote
origin
test

C:\Users\gwolf\Documents\gittest>git fetch test
warning: no common commits
remote: Counting objects: 2, done
remote: Finding sources: 100% (2/2)
remote: Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From https://git.hana.ondemand.com/<SubaccountB>/gittest
 * [new branch]      master     -> test/master

C:\Users\gwolf\Documents\gittest>git merge --allow-unrelated-histories test/master

C:\Users\gwolf\Documents\gittest>git push test
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (12/12), 1.22 KiB | 250.00 KiB/s, done.
Total 12 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
To https://git.hana.ondemand.com/<SubaccountB>/gittest
   470c9c7..914719c  master -> master

This results in the complete history being available in the SubaccountB:

manuel_baehr
Explorer
0 Kudos

These solution is quite good, but not woking completly:

It works for a directory, where all commits are belonging to my user.

But if I try it out with a productive repo, where other users have participated, I get the error:

ERROR: In commit x123y committer email address not_my_mail@xy.com does not match your user account.
The following address is currently registered for you: my_mail@yx.com

Afterwards the target repo is still empty.

gregorw
Active Contributor
0 Kudos

As you see on the different names I've used also different users also with different E-Mail addresses to commit the changes in the repository of SubaccountA. And the migration to SubaccountB worked without issues.

manuel_baehr
Explorer
0 Kudos

Yes, I see it. That's actually weird, I did exactly the same. Are your users somehow associated with each other?

gregorw
Active Contributor
0 Kudos

The one user is a S-User and the other is a P-User. The P-User has only access to the SubaccountA. And I did the migration with the S-User.

gregorw
Active Contributor

Yes, that is possible. You clone the repository from sub-account A to your local system, add the repository from sub-account B as a remote and push it there. I would suggest to have a look at the great OpenSAP Course: SAP Cloud Platform Version Control with Git.

manuel_baehr
Explorer
0 Kudos

But on this way you have to confirm each commit manually and if the commit was not done by your user, you have to overtake it in a manual way. Isn't it?

gregorw
Active Contributor
0 Kudos

I don't think so. Why don't you just give it a try with a sample test repository?

manuel_baehr
Explorer
0 Kudos

I did, but it happend exactly this. That's not really practical, for repos with around 150 commits, to pass commands by hand for every commit.