Business- technology - Educational- Politics -Software

Friday, November 29, 2019

Git branching strategy and solutions to branch merging issue .

Git common problems and their solutions :

Git strategy

Branching Strategies:
If you want to have a smooth development cycle than you must have a good branching Strategies. A good Branching strategies helps team to develop their codes without any conflicts and while pushing for release  . Changes to the branch don't affect other developers until the developer or team has tested the changes and decides to merge the code. Developers can still pull down changes from other developers to collaborate on features and ensure their private branch doesn’t diverge too far from the main code line. different organizations uses different branching strategies  but there are few very frequent way to do branching , they are given below .
  1. No branching Strategies:In this case there will not be any branch all developers will work on the same central repository and they can merge their branches with central branches after proper testing.This type of strategies mostly followed in smaller team were internal testing is very good and all developers are working in sync .

    For any larger team this strategies will work very well , because if any bug and issue will be there in any merge it will be very hard to fixed it and find the proper solution for it . Many time it take too much time to release a small feature . Any larger team or team which seats globally should avoid this strategies .
  2.  Release Branching: This strategies is most common , in this strategies there will be a release branch taken from live branch that may be master branch , and all developers will work on this branch till next release . Only problem with this branch if scrum go longer than two week than it will be very hard to manage .We should only go with if we have very smaller release and scrum should be of 2 week maximum .
    This strategy is most commonly used in waterfall and Scrummerfall development processes.
  3. Feature Branching:This branching strategies are very good for faster and smoother development cycles . In this every developers makes a branch with name of their feature for example user_name , and once testing done with this branch developer can merge their branches with master branch.Again if proper understanding not maintained during development this strategies can also be go like Release branching , if time for release go very longer and changes are getting bigger and bigger.
  4. Story or Task Branching:In this every branch is associated with a task on id , which means managers can divide story into multiple branches and can with associate each branch with some task of any big story.In this strategies managers can release very frequently as he can divide task into smallest part and can assign this task to some branch . These branches are completely independent of other task so can be independently releases .
 Merging Strategies
  1. Merging is very important in git , as many time because of code conflict features did not reflect properly and testers keep blaming , and this could lead to delay in already developed features .merging can be done by mutual code review .Many organization try to make more and more repose and smaller code as in such situations there are very less possibility for code conflict .In some cases developers keep updating their work within the team  so that others will aware of upcoming conflict.

  2. Some basic tricks to merge branches and code:
    1.  Suppose there are many commits  on the branch which we are planning to merge and many of the commits are not clear .
      Solution .we can use cherry pick also in cherry pick we go to the git commit logs and select the the commit id’s and merge those id’s with with branch.
      Let's take an example,
      Master branch =>master
      Feature branch=>feature_branch
      Git checkout feature_branch
      git log --author="Jon"
      Log1_id
      Log2_id
      Log3_id
      Here we are looking at each commit of user Jon and we can ask him to which commit need to go live and which one not .
      Next things we need to do cherry-pick
      git checkout master
      Git cherry-pick Log1_id
      Git cherry_pick Log2_id
      And here we have merged two logs.

No comments:

Post a Comment