0

I'm working on a program to migrate multiple repos from a git server to a Gitlab one. The migration part is already done and now I want to check if everything went okay and that all the repos were migrated properly.

What is the best way to do that ?

ibizang
  • 3
  • 1
  • What you are looking for.? – Snopzer Jun 14 '16 at 10:56
  • A way to compare the original git repositories with the migrated ones. – ibizang Jun 14 '16 at 11:14
  • Okay, you can do it by login to a repository and and run `git diff master remotes/b/master` [Visit](http://stackoverflow.com/questions/1968512/getting-the-difference-between-two-repositories) for more details. – Snopzer Jun 14 '16 at 11:23
  • You should tell how you are migrating the repos. There is no need for checking anything if you just change the upstream URL. – Kai Jun 14 '16 at 11:27
  • @MohammadFareed thanks man, It worked and it's exactly what I need. – ibizang Jun 17 '16 at 12:32

3 Answers3

0

Clone the code from gitlab

git clone <gitlab-repo-url>

Add the git server repo url as a remote on your local repo

cd <repo>
git remote add oldserver <git-server-repo-url>

Run git fetch for both remotes

git fetch --all

Run git log showing commits from all your remotes

git log --decorate=short --oneline --remotes=* --branches=*

If you see both remotes master branches pointing to the same commit, it's a strong indicator migration went well

e4bf7c2 (master, origin/master, oldserver/master) Latest commit message
9d5339c A previous commit message
fe43ce7 Other commit message

origin/master is the master branch on gitlab
oldserver/master is the master branch on old git server

everton
  • 7,579
  • 2
  • 29
  • 42
0

In repo_a:

git remote add -f b path/to/repo_b.git
git remote update
git diff master remotes/b/master
git remote rm b
Snopzer
  • 1,602
  • 19
  • 31
0

I know it's an old question but I ran into the same requirement recently. I was thinking to find a tool to solve it but with no luck. After some searching here's a solution to compare two whole repo not only a specific branch.

git clone --mirror path/to/repo_a.git old/repo_a.git
git clone --mirror path/to/repo_b.git new/repo_b.git
git diff --name-only --no-index old/repo_a.git new/repo_b.git | wc -l | xargs test 1 -lt && echo 'repo not the same!'

clone with --mirror option will clone the whole repo without working tree into a directory. diff with --no-index could be used to compare the whole directory. If the content of repo are the same, then only the url in config file will be different.

P.S. You'll have to clone both repo with the same protocol. For some unknown reason it'll produce different file when using different protocol. That way the output of diff will indicate more difference.

haudoing
  • 603
  • 7
  • 18