How to work efficiently with branch in git?

12

I'm trying to define a working schema to keep my repository in GitHub organized, but it's hard to come up with a solution.

My "idea":

I thought about keeping the branch master (default) and develop in the remote repository. The master branch will be blocked , it will only accept merge after the pull-request revision, ie collaborators will send their contributions to develop and generate a pull request from this to the master.

The branch feature / xpto, hotfix / xpto and others will be branched from develop , I do not know if it would be interesting to branch further with topic branch usage. Before you merge the local branches with develop , you must evaluate the need to apply a full rebase or some commit, aiming to keep a historical line clean and easy to read , after the local merge and the push to the remote, a pull-request of master <- develop should be generated in GitHub.

In the text thus it was possible to observe some doubts, we will consolidate them and some more:

  • In practice branch topic are really useful and used?
  • Local rebase before push is a good idea, in what situation would it be advisable?
  • Would it be better to change my CHANGELOG.md file in the develop branch, or create a branch release, change there and then merge with master and develop ?
  • When performing a merge of master
asked by anonymous 10.03.2018 / 00:04

2 answers

4

I think GitFlow is an efficient and organized approach, below is a link and image to illustrate better:

link

    
10.04.2018 / 23:48
0

Come on, since many of the doubts continued to hammer in my head, I decided to study the subject a little more in depth. Considering the knowledge acquired, I will try to answer the questions that once represented absolute doubts:

  • In practice, are branch topic really useful and useful?
  

Branch topic can be used to have greater control of "long" flows of development. Functions that generate many steps can be divided into branch topic, so a more detailed timeline can allow more controlled partial regressions; In this case the branch topic is relevant (useful), so it is a good scenario to use this approach.

  • Local rebase before push is a good idea, in what situation would it be advisable?
  

Yes, it is valid for changes that have not yet been pushed to the remote repository. Situations can be as many as possible, such as a commit to change an incorrect comment in the code, fix an error that should not be present in the previous commit, such as forgetting a line delimiter, and so on. In summary, especially when we generate some unnecessary commit, but use this feature wisely, try not to rebase if you have already committed the commit to the remote.

  • Would it be better to change my CHANGELOG.md file in the develop branch, or create a branch release, change it there and then merge it in master and develop ?
  

Preferably in the branch release, this is a branch created to prepare the release of a new version ... In this branch, we can consolidate a CHANGELOG already with the appropriate references for the commit that contain the changes there, change data in the README or make other minor adjustments.

  • When performing a merge of master
17.04.2018 / 05:30