Files
blog/posts/git-workflow.md
Guus Waals 29502f6816 Initial commit
Initial commit

Add lua template
2025-10-24 19:24:07 +08:00

1.5 KiB

Git Workflow Best Practices

Git is an essential tool for modern software development. Here are some best practices for an effective Git workflow.

Branching Strategy

Main Branches

  • main/master: Production-ready code
  • develop: Integration branch for features

Supporting Branches

  • feature/: New features
  • bugfix/: Bug fixes
  • hotfix/: Urgent production fixes

Commit Messages

Good commit messages are crucial:

Add user authentication system

- Implement JWT token generation
- Add login and logout endpoints
- Create user session middleware

Follow the 50/72 rule:

  • First line: 50 characters or less
  • Body: Wrap at 72 characters

Commands

Creating a Feature Branch

git checkout -b feature/new-feature develop

Committing Changes

git add .
git commit -m "Add feature description"

Merging

git checkout develop
git merge --no-ff feature/new-feature
git branch -d feature/new-feature

Tips

  1. Commit Often: Make small, logical commits
  2. Pull Regularly: Stay in sync with the team
  3. Review Before Commit: Use git diff to check changes
  4. Use .gitignore: Don't commit build artifacts or secrets

Advanced Features

Interactive Rebase

Clean up commit history:

git rebase -i HEAD~3

Stashing

Save work in progress:

git stash
git stash pop

Cherry-pick

Apply specific commits:

git cherry-pick <commit-hash>

Master Git, and you'll be a more effective developer!