github - bit bucket mirroring
Requirement:
We have a project deployed using version controller github and need the same code in bitbucket with commit history and both repositories should be in synchronized as there is continuous deployment
# Clone the git repository that you want to merge to the bitbucket repository branch
git clone git@github.com:<github_user_name>/<github_repo_name>.git
# Rename origin to github
git remote rename origin github
#Add the bitbucket as a remote to the cloned repository. Replace<bitbucket_repo_url> with the URL of the bitbucket.
git remote add bit <bitbucket_repo_url>
#Fetch the branches and commits from the bitbucket
git fetch bit
#checkout to the bitbucket branch,
git checkout bit
#Attempt to merge the github into the bitbucket. Use the --allow-unrelated-histories flag to force Git to merge the unrelated histories.
git merge --allow-unrelated-histories bit/<branch_name>
#Resolve any merge conflicts and commit the changes and push the merged changes to the Bitbucket repository.
git push bit<branch_name>
Comments
Post a Comment