DEV Community

A.R
A.R

Posted on

Be a better developer with these Git good practices

If you're a developer, Git is likely a part of your daily routine. Efficiently using this versioning system is crucial for the development process, whether you're working independently or in a team. However, it's common to encounter messy repositories, unclear commit messages, and branch misuse. Knowing how to use Git correctly and following best practices is essential for excelling in the job market.

Table of Contents
Naming Conventions for Git Branches

Lowercase: Stick to lowercase letters.
Hyphen Separated: Use hyphens for multi-word branch names.
Alphanumeric Characters: Use only letters, numbers, and hyphens.
Avoid Continuous Hyphens: Instead, use slashes for branch types.
Avoid Ending with a Hyphen: Ensure branch names are meaningful.
Descriptive Names: Use clear, concise, and descriptive names.
Examples of Good Branch Names:

feature/new-sidebar
add-new-sidebar
hotfix/interval-query-param-on-get-historical-data
Branch Names Convention Prefixes

Use prefixes to indicate the purpose of a branch (e.g., feature, release, bugfix).
Examples:feature/add-filters
release/v3.3.1-beta
bugfix/sign-in-flow
Task Management Integration:

If using tools like Jira or Trello, include card numbers in branch names.feature/T-531-add-sidebar
docs/T-789-update-readme
hotfix/T-142-security-path
Commit Message

Follow conventional commit standards.
Use imperative mood, capitalize, and limit the subject line to 50 characters.
Separate subject and body with a blank line.
Wrap body at 72 characters, use bullet points if needed.
Examples:feat: add user authentication
fix(ui): resolve issue with button alignment
Conventional Commits

Follow the structure: [optional scope]:
Types include feat, fix, refactor, chore, docs, perf, style, test, build, ci, env.
Examples:chore: add commitlint and husky
feat(page/home): create next routing
chore!: drop support for Node 18
With Subject, Body, and Footer:

feat: add function to convert colors in hexadecimal to rgbaThis commit introduces a new module for converting colors.
Reviewed-by: 2
Refs: #345
Breaking Change

Indicate significant changes that may affect compatibility.
Use "BREAKING CHANGE" in the footer or add ! after type/scope.

Top comments (0)