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
```
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
```
You can find the script on [my gist on github](https://gist.github.com/animusna/39178047985d431c8bc86de7be894f8c).
Suggestions, corrections and improvements are welcome!
See you soon ;)
Top comments (8)
Doesn't it break the gitflow itself?
I mean, you code on a feature/branch, then integrate on Develop and merge to Master. At this point you already have Develop and Master sync-ed
No, it doesn't. The goal of the script is to maintain sync the local master and develop branches with remote repository automating sync commands.
For instance you can run the script before each git flow start command like a new feature
and before and after of each git flow finish command
In this way you are sure to start and finish with an updated develop branch and to sync your main local branches (develop and master) with remote repo.
See you.
I keep misunderstanding what issue this solves.
If you mean that this script only sync local develop with remote develop, and local master with remote master, i assume it's the same than performing checkout (develop or master) and pull. Nothing else.
Then you need to checkout again your working branch manually
Am I wrong?
You are not wrong the script run checkout and pull of master and develop, but sometimes the sync could be bidirectional so you have to push your updated branches to the remote repository executing other commands.
For instance when you finish a release you have to run at least three commands to update the remote repository (develop and master):
The script permit you to stay synchronized running one command instead of running the same number of git commands for each branch (develop and master).
The issue solved is to not repeat the same commands for each branch especially when you update very frequently your code base.
Nice, I see the use case now.
I've been using git console commands for a while but finally I moved to GitKraken which adds useful extra features (no more pain on Merges, GBoards, issues sync with github, gitlab...), you must take a try :)
GitKraken it's cool, thanks for the invitation! :)
I'll try it, even though I'm little bit console addicted ;)
I need to waste my time coding instead on dealing with the VCS, specially when there's a merge that needs attention because auto-merge failed, so it's a nice tool for that as you can pick chunks of code from a file or another in the file compare window when merging.
I'm also loving the ability to sync with some Git servers, specially the issues tracker, hope it helps to you :D
I understand, productivity it's important and for this reason sometimes I also use gui tools. What I use it's up to scenario I'm facing.
See you ;)