Dwarves
Memo
Type ESC to close search bar

Gitflow Pull Request

Git is one of the most popular source control. Github is one platform built over the top of Git and well adapted by lots of companies. Knowing the right workflow will help to increase the team productivity. In this post, I will try to cover some of the best practices from the community and the way we applied them at Dwarves Foundation.

Git branching mode

Source: https://nvie.com/posts/a-successful-git-branching-model/

In sort, you will organize your repository into 5 types of branches:

The main branches

Feature

Feature branches (or sometimes called topic branches) are used to develop new features for the upcoming or a distant future release. When starting development of a feature, the target release in which this feature will be incorporated may well be unknown at that point.

Release

Release branches are created from the develop branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of develop is ready for the “next release” and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number

Hotfix

Hotfix branches are very much like release branches in that they are also meant to prepare for a new production release, albeit unplanned. They arise from the necessity to act immediately upon an undesired state of a live production version. When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the master branch that marks the production version.

Gitflow

Inspired by Vincent Driessen’s branching model, git-flow are a set of git extensions to provide high-level repository operations for it. Git-flow is a merge based solution. It doesn’t rebase feature branches.

For now, you can continue to read the article GitFlow considered harmfulto know more about the author issue.

How to write commit message

Source: http://chris.beams.io/posts/git-commit/

Have you ever read some repos with commit messages like above?

While many repositories’ logs look like the former, there are exceptions. The Linux kernel and git itself are great examples. Look at Spring Boot, or any repository managed by Tim Pope. The contributors to these repositories know that a well-crafted git commit message is the best way to communicate context about a change to fellow developers (and indeed to their future selves). A diff will tell you what changed, but only the commit message can properly tell you why.

Being known that, a project’s long-term success rests (among other things) on its maintainability, reviewing others commits and pull requests is also the big reason that you should write great commit messages.

Pull Request

Pull request is a feature that makes it easier for developers to collaborate. Pull request is a mechanism for a developer to notify team members that they have completed a feature.

Some tricks to make Pull Requests more awesome for your project:

Pull Requests are a great way to start a conversation of a feature, so start one as soon as possible- even before you are finished with the code. Your team can comment on the feature as it evolves, instead of providing all their feedback at the very end.

No one has a fork of github/github. We make Pull Requests in the same repository by opening Pull Requests for branches.

Pull Requests are easy to make and a great way to get feedback and track progress on a branch. But some ideas don’t make it. It’s okay to close a Pull Request without merging; we do it all the time.

Hint: Based on an article Type of Pull Request, there are 6 types of PR. But WIP pattern is the one that is using by lots of teams and companies. It follows the mantra of “Open a Pull Request as early as possible”.

Code Review

Source: https://github.com/thoughtbot/guides/tree/master/code-review

Everyone

Having Your Code Reviewed

Reviewing code

Understand why the change is necessary (fixes a bug, improves the user experience, refactors the existing code). Then:

Rebase vs Merge

Source: https://blog.sourcetreeapp.com/2012/08/21/merge-or-rebase/

Merging Pros

Merging Cons

Rebase Pros

Rebase Cons

Note: Other post from Atlassian: https://www.atlassian.com/git/tutorials/merging-vs-rebasing

Git Templates

To make things easier, we have adopted Issue template and Pull Request template that we think they are great to help the team to improve the productivity.

[Issue Template]

<!--
Please use the following template to submit your issue. Following this template will allow us to quickly investigate and help you with your issue. Please be aware that issues which do not conform to this template may be closed.
-->

### Status
BUG REPORT / TASK

### Checklist
Add checklist if this is a task

- [x] Add Facebook login
- [ ] Support X

### Steps to reproduce
1. First step

2. Second step
3. Third step

### Expected behaviour
How do you think the program should work? Add screenshots and code blocks if necessary.

### Actual behaviour
How does the program work in its current state?

### Environment
You may write here the specifications like the version of the project, operating system, or hardware if applicable.

### Logs / Stack trace
Insert your log/stack trace here