Engineering · Git

GitHub Best Practices: Feature Development Workflow

A short guide to the workflow I use for new features — branching from a clean main, naming conventions, and the small habits that prevent merge pain.

Eagle Lo··
  • git
  • github
  • workflow

Key takeaways

  • Always start with a clean, up-to-date main branch.
  • Use git fetch followed by git pull to sync with remote.
  • Create feature branches with descriptive names.
  • Follow a consistent branching strategy.
  • Keep your feature branches focused and small.

Starting a new feature: the right way

When beginning work on a new feature, it's crucial to start with a clean slate.

1. Sync with the main repository

First, ensure your local repository is up to date with the remote:

# Fetch all changes from remote
git fetch origin

# Switch to main branch
git checkout main

# Pull the latest changes
git pull origin main

This two-step process (fetch then pull) is important because:

  • git fetch downloads all changes from the remote repository without merging them.
  • git pull combines fetch and merge into one command.
  • Using them separately gives you more control and visibility into what's changing.

2. Create a new feature branch

Once your main branch is up to date, create a new branch for your feature:

git checkout -b feature/your-feature-name

Best practices for branch naming:

  • Use descriptive names that reflect the feature or fix.
  • Follow a consistent naming convention (e.g., feature/, bugfix/, hotfix/).
  • Use hyphens or underscores for multi-word names.
  • Keep names concise but meaningful.

3. Start development

Now you're ready to start coding. Your new branch is based on the latest version of main, and you can make changes without affecting the main codebase.

A few habits worth keeping:

  • Make frequent, small commits.
  • Write clear commit messages.
  • Keep your feature branch focused on a single task.
  • Regularly push your changes to the remote repository.

Why this approach matters

Following this workflow ensures:

  1. You're working with the latest code.
  2. Your changes are isolated in a dedicated branch.
  3. You minimize merge conflicts.
  4. Your work is properly tracked and can be reviewed.

Common pitfalls to avoid

  • Starting development without syncing with main.
  • Working directly on the main branch.
  • Creating branches from outdated code.
  • Using vague or inconsistent branch names.

Next steps

In the next article we'll cover writing effective commit messages, managing pull requests, code review best practices, and handling merge conflicts.

A clean development workflow is the foundation of successful collaboration in any software project. Taking the time to follow these practices will save you from headaches down the road.