Development Guidelines
Git Guidelines
This guide outlines the standard Git workflow and best practices for Laravolt projects.
Workflow
Git workflow defines our branching strategy when using Git for software development, covering:
- How to name branches?
- When to create a new branch?
- When can deployment be done?
- Which branch should new branches be created from?
- Where should branches be merged when completed?
- How to handle production bugs?
- And other branching strategy concerns
There are two methods commonly used as references:
- GitFlow (ideal version for product development, relatively more complex, suitable for large teams and project scopes)
- Github Flow (simple, suitable for small teams and projects)
Each method has its own advantages and disadvantages. In our journey, we've implemented a new method that's appropriate for developing information systems in South East Asia, called Simplified Git Flow.
Simplified Git Flow
- There should always be at least 2 branches:
main
is the (protected) branch ready for deployment to production.develop
is the (protected + default) branch actively used during development. Testing is done on this branch.
- When programmers start working on something, they create a new branch from
develop
following the branch naming rules (see below). - If there's a bug in production, programmers create a hotfix branch from
main
. Once completed, merge todevelop
for testing (don't delete the hotfix branch) and if it passes testing, continue by merging that hotfix branch tomain
. - Periodically (usually weekly), after passing testing, the
develop
branch is merged to themain
branch and automatically deployed to production.- At this stage, a tagging new version process can be done to make referencing easier. So if there's a bug, we can say "oh, this appeared since version 1.1" and not "oh, this appeared 2 or 3 weeks ago".
Branch Naming
- Branch names should be written in kebab-case format
- Two mandatory branches are:
main
as the main branch. Merging tomain
means promoting to production.develop
as the development branch. Merging todevelop
means promoting to staging.
- According to the task type, branch names must begin with one of these prefixes:
feature/
for new features or enhancements to existing featuresissue/
for bug fixeshotfix/
for critical bug fixes that need immediate deployment to productionrefactor/
for code improvements without adding new featuresstyling/
for UI improvements without adding new features
Previously, we knew the default branch name commonly used was
master
. But since 2020, the termmaster
has been replaced withmain
. References related to this change:
Examples
✅ Good
feature/crud-faq
feature/mockup-login
issue/password-edit-failure
hotfix/remove-hardcoded-userid
refactor/cleanup-user-controller
styling/login-page
styling/enlarge-topbar-searchbox
❌ Bad
crudFaq
password_edit_failure
hotfix_remove-userId
ui-improvements
(Which UI?)feature/john
(avoid using personal names)
Commits
- Before committing, review the list of modified files and ensure there's no junk code.
- If you find unrelated changes that you want to keep, use
git stash
.
Commit Messages
Allocate at least 30 seconds to remember why you made those changes. Write the answer to that why question as your commit message. Do this under any circumstances, relaxed or under pressure. Delaying a commit for 30 seconds won't cause World War III.
Examples
❌ Bad | Why Bad? | ✅ Good |
---|---|---|
Fix product rating | Too general | Fix product rating: handle null rating values |
Fix bug | Too general | Fix admin role check when deleting comments |
Add validation | Too general | Add product price validation: minimum input value of "0" |
Grocery page 404 | Ambiguous | Fix 404 when accessing grocery page due to incorrect route order |
Error message appears if profile incomplete | Ambiguous | Show error message when profile is incomplete<br />or<br />Remove error message even when profile is incomplete |
remove whitespace in PartnerController.php line 217 | Too specific | Remove whitespace causing blank response |
search button filter kost | Too general | Adjust "Search" button size on kost filter page |
styling searchbox | Too general | Make searchbox more contrasting and visible |
fixing mobile view | Too general | Adjust search page layout to match Zeplin design |
migration | Too general | migration: add item_task column |
change migration | Too general | migration: make users.name column nullable |
Pull/Merge Requests
- Before creating a Pull/Merge Request, ensure:
- Your commit messages follow the guidelines
- You've performed self-testing
- You've removed all
comments
andunused debugging code
- Provide an explanation of what was added or changed. If you're using a task management system (ActiveCollab, Jira, Trello, Basecamp, etc.), simply include a link to the relevant task.
- Assign to the designated Reviewer.
- If changes are needed, the Reviewer changes the
Assignee
back to the original programmer. - After making changes, the programmer changes the
Assignee
back to the Reviewer. - When everything is satisfactory, the Reviewer:
- Approves the request
- Deletes the merged branch
- Performs squash commits if necessary
Code Review
Code review in a PR/MR is a unique learning process because many cases will be encountered by the Programmer for the first time, but the Reviewer has experienced them repeatedly. Therefore, questions sometimes arise: "It's already working, why do we need to change it?"
This is where natural knowledge transfer happens. The Programmer provides solutions based on current conditions, and the Reviewer provides input based on future possibilities. Programmers can gain a lot of experience without having to experience it themselves. Software quality is better maintained.
It's a win-win solution.
Reviewer Checklist
- Code follows standard style guidelines
- Code changes align with the PR/MR
- No hardcoded rules
- If there are lengthy code portions that aren't understood, ask for explanations
- Each migration script should be accompanied by appropriate seeders
.gitignore
.gitignore
contains a list of files and folders not included in the git index. These typically have characteristics such as:
- Contains configurations that differ for each programmer, like
.env
. - All folders for storing user-uploaded files.
- All folders generated automatically by the application, such as JS or CSS compilation results.
- All folders generated by the OS and editors/IDEs like Sublime Text, Visual Studio Code, or PHPStorm.
- For convenience, you can use https://www.gitignore.io/ to get commonly used
.gitignore
files.
Common Mistakes
Setting Default Branch to main
When a programmer clones a repository, they should immediately get the code that's actively being developed, which is the develop
branch. Remember, the main
branch is for production deployment, while the develop
branch is for active development.
Naming Default Branch dev
develop
is more commonly used. dev
itself has a special meaning in composer, so it's better to avoid it.
Not Deleting Merged Branches
Undeleted merged branches become clutter and disrupt the developer experience.
The ideal number of branches is 2 + (2 x number of programmers). For example, if 3 programmers are involved at one time, the number of branches should not exceed 8.
Author Name Duplication
Some programmers use multiple tools for committing: git command line, git kraken, sourcetree, or fork. Problems arise when each tool has different configurations regarding the identity used for commits.
Make sure each tool is set up with uniform names and emails. Alternatively, configure git to use the same identity.