How to merge two repos
Just imagine we have two git repos and one of them haven’t update a lot of time. We want to merge it. How we should to do it the situation. Don’t forget exists lasted changes in repo
$ git fetch -ap
$ git pull
First of all we need add remote source
$ git remote add gerrit ssh://gerrit.com:29418/XXX/XXX
Check it. Should be two remotes origin and second remote url gerrit
$ git remote -v
# Output
gerrit ssh://gerrit.com:29418/XXX/XXX (fetch)
gerrit ssh://gerrit.com:29418/XXX/XXX (push)
origin https://github.com/YYYY/YYYY (fetch)
origin https://github.com/YYYY/YYYY (push)
Call master branch from other remote with prefix. That action to do more easy to filter in git log and merge branch in future
$ git checkout -b gerrit gerrit/master
Now need choice branch with missing changes
$ git checkout gerrit
Merge changes from origin repo which contain lasted changes
$ git merge origin/master
Add new commit
$ git commit -a -m "Sync"
I recommend to use squash, if we wouldn’t like add each commit separately
$ git rebase -i gerrit/master
Finally push to gerrit repo
$ git push gerrit HEAD:refs/for/master
It is all.