Git Repo Sync: Simple Bash script to sync master and develop branches for a classic Git Flow Branching Model

Aniello Musella - Aug 29 '20 - - Dev Community

I wanna share an useful bash script (at least according to me ;)) that I wrote to make easier the synchronization of one or more repositories in a git flow branching model that many of you know and use daily to version your code base (if you don't know what's a git flow branching model please refer this link).

This script has the goal to synchronize the branches develop and master from local to remote repository.

To know how to run the script type :

animus@host:~$./repo.sync --help
Enter fullscreen mode Exit fullscreen mode

and you get the usage of the script and all of possible options.

usage: repo.sync [OPTION]... DIRECTORY... 
Sync a Git repository for a DIRECTORY (one or more) representing a git repository where is activated a Git Flow branching model.

Options:
--noPushOnProdBranch        Skip git push on production branch
--noPushTagsOnProdBranch    Skip git push tags on production branch
--noPullOnProdBranch        Skip git pull of production branch from remote.
--noPushOnDev               Skip git push on develop branch
--noPushTagsOnDev           Skip git push tags on develop branch
--noPushTagsOnDev           Skip git pull of develop branch from remote.
--mergeProdInDev            Make a merge from production branch into develop branch (Warning: this breaks git-flow branching model).
--help                      Display this help and exit
Enter fullscreen mode Exit fullscreen mode

You can find the script on my gist on github.

Suggestions, corrections and improvements are welcome!

See you soon ;)

. . . . . . . . . . . . .