Recently, we have migrated code from Bitbucket to GitHub repository. I would like to know if there is any git command to compare the branches between Bitbucket and GitHub. This comparison is to check / verify if all the code has been migrated properly.
One option I have tried is that, to checkout code from both the branches (from Bitbucket and GitHub) and compare using the folders using beyond compare or some comparison tools. But would like to know if there is any git command, that we can use to compare the branches efficiently.
You just need to fetch the changes from both remote repositories, and then perform a git diff
between the two tracking branches.
Say origin_bit_bucket
and origin_git_hub
represent respectively the remote repositories on BitBucket and GitHub, you could run:
git fetch origin_bit_bucket my_branch
git fetch origin_git_hub my_branch
git diff origin_bit_bucket/my_branch origin_git_hub/my_branch
In the explanation above, I assumed that your remotes had already been added to your local repository since you've stated: "Recently, we have migrated code from Bitbucket to GitHub repository." So, because you're in this in-between phase, I figured that the two remotes were already present in the repo.
However, in case they're not, you can add multiple remote repositories with the git remote
command, specifically with the add
subcommand, and name them with appropriate handles.
git remote add origin_bit_bucket <Bitbucket_repo_URL>
git remote add origin_git_hub <GitHub_repo_URL>