Git Tip #4 - A 2-way sync

If you want to do a 2-way sync of a particular git branch use the recipe below.


    rm -rf sync
    mkdir sync
    cd sync

    git --version
    git init
    git config credential.helper store

    git remote add one http://username@one.com/repo.git
    git remote add two http://username@two.com/repo.git

    git pull one master
    git pull two master

    git push one master
    git push two master

    git fetch one --tags
    git fetch two --tags

    git push one --tags
    git push two --tags
        

NOTE before you can completely automate the script above you will have to manually do each of the steps once on the machine you are going to run the script on. Once that is done you can turn the automation on.

Posted October 17, 2016

Up