This blog moved to medium->https://medium.com/@cocoamaemae

Sunday, May 14, 2017

How to use gitmumerge, merge multiple git branches automatically


Brief

Explain about gitmumerge which is introduced in consideration about how to merge multiple git branches.


gitmumerge


It's just a wrapper of cui git client. It is possible to make executing multiple "git merge" automation. 'mu' means 'mutual'.
https://github.com/cocoa-dev-maemae/gitmumerge

Requirements

Currently, it can work only on bash. Whatever OS is ok. CUI git clinent is essential. Install before using.


(debian)
sudo apt-get install git
(redhat)
sudo yum install git



Install gitmumerge

clone with git and create path

git clone git@github.com:cocoamaemae/gitmumerge.git ~/.gitmumerge
echo 'export PATH="$HOME/.gitmumerge/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc


# confirm version
gitmumerge -v


How to use gitmumerge


At first, clone a git repository which you want to merge, and move to a clone directory.

(e.x.)
git clone <target repository paty>
cd <clone directory>

And then, gitmumerge chance.  Specify the final merge target branch after -d(--destination-branch) and specify the development branches after -c(--candidate-branches)

(exp)

gitmumerge -d master -c dev1 dev2 dev3

Executing the exp, master->dev1, dev1->master, master->dev2, dev2->master, master->dev3, dev3->master order merging is executed. Before merging is executed, [Y/n] is displayed. If the conflict occurs, exit forcibly.


"Merging branches has done" is the exit message. The merging is executed only on client side. So push the branch which is specified after -d(--destination-branch). The operation is manual currently.





Tuesday, May 9, 2017

Best practice when merging multiple git branches


It is general to create multiple branches and manage them parallel when we do the development by using git. Multiple branches should be merged to one branch after the development has done. Here, think about how to merge git multiple branches to one branch finally.

Basic merging way

For example, there would be multiple branches, dev1, dev2 and dev3, which are created from master branch. Have you ever merged them to master branch like Fig.1?

Fig.1


Very simple merging way, so a lot of developers might have merged branches like this. However, this way has a fault. There is a possibility to remove other's modifications.
In Fig.1, dev1 branch is merged at first. So dev2 branch merging may remove dev1 modification, or dev 3 branch merging may remove dev1 or dev2 modifications.

To avoid overwriting to other branch modifications

If you avoid overwriting to other branch modifications, doing like Fig.2 is correct.

Fig.2

















In this way, dev1 modifications are merged to dev2 branch before dev2 branch would be merged. dev1 and dev2 modifications are merged to dev3 branch before dev3 branch would be merged. There is no possibility to remove other modifications.

The rest issues

If we user Fig.2 way, we can avoid overwriting to other branch modifications However, the procedure will be complex. 
So I created gitmumerge which is created by ShellScript, to make Fig.2 procedure automation. It will be introduced in the another post.




Front End Development Tools

TaskRunner Tool executing multiple tasks by only one execution. Tasks are like CSS preprocessor, Transpire, Module Bundler, etc... e.g. ...