You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何规范搭建用于客户交付的Git工作流?

Got it, let's put together a Git workflow that perfectly matches your requirements—keeping your core codebase stable in master, maintaining a dedicated branch for this client, and leaving room for future customizations for other clients down the line. Here's a step-by-step breakdown:

1. Core Branch Structure

First, let's formalize the branch setup you're targeting:

  • master branch: This is your stable, production-ready core codebase. It only contains fully tested, universally compatible code that serves as the foundation for all client customizations. No client-specific code ever lands here.
  • Client-specific branch (e.g., client-acme-v0.1): A dedicated branch for your current client. This branch will hold all custom features, tweaks, and configurations tailored exactly to their needs—this is the branch you'll use to deploy to their server.
  • Feature branches (e.g., feature/acme-payment-integration): Short-lived branches for developing individual features/fixes for the client. Once tested and approved, they get merged into the client's dedicated branch (not directly into master unless the feature benefits all future clients).
2. Step-by-Step Workflow Implementation

2.1 Set Up the Client Branch

If you're starting from an existing master branch:

# First, make sure you're on the latest stable master
git checkout master
git pull origin master

# Create the dedicated client branch (use a clear name tied to the client and version)
git checkout -b client-acme-v0.1

2.2 Daily Development for the Client

For every new feature or bug fix for this client:

  1. Spin up a feature branch off the client's dedicated branch:
    git checkout client-acme-v0.1
    git checkout -b feature/acme-custom-checkout
    
  2. Develop, commit, and push your changes to the feature branch:
    git add .
    git commit -m "Add ACME-specific coupon validation to checkout"
    git push origin feature/acme-custom-checkout
    
  3. Once the feature is tested and ready, merge it into the client's branch (use --no-ff to keep a clear history):
    git checkout client-acme-v0.1
    git merge feature/acme-custom-checkout --no-ff
    git push origin client-acme-v0.1
    # Clean up the feature branch once done
    git branch -d feature/acme-custom-checkout
    git push origin --delete feature/acme-custom-checkout
    

2.3 Delivering to the Client

When you're ready to deploy a working version to their server:

  • Double-check that the client branch (client-acme-v0.1) is fully tested and stable.
  • Tag the version for easy tracking (this lets you pinpoint exactly what's deployed):
    git tag -a v0.1-acme -m "ACME client v0.1: initial production deployment"
    git push origin v0.1-acme
    
  • Deploy directly from this client branch to their server (you can use git pull on the server, or set up a simple CI/CD pipeline if you want automation).

2.4 Syncing Core Improvements to Client Branches

If you fix a critical bug or add a universal feature to master that the client should receive:

# Switch to the client's branch
git checkout client-acme-v0.1
# Merge the latest master changes into it
git merge master
# Resolve any conflicts, test thoroughly, then push the updated client branch
git push origin client-acme-v0.1

2.5 Preparing for Future Clients

When you need to build for a new client later:

  1. Create a fresh dedicated branch from the latest master:
    git checkout master
    git pull origin master
    git checkout -b client-bob-v0.1
    
  2. Repeat the feature branch workflow for the new client—their customizations stay completely isolated from master and other client branches.
3. Best Practices to Keep Things Clean
  • Never commit directly to master or client branches: Always use feature branches for development to avoid breaking stable code.
  • Sync client branches with master regularly: This ensures clients get core bug fixes and improvements without falling behind.
  • Stick to clear naming conventions: Branch names like client-[name]-[version] and feature/[client-name]-[feature] make it easy to track what's what at a glance.
  • Tag all deployments: Tags act as a safety net—you can quickly roll back to a working version if something goes wrong on the client's server.

内容的提问来源于stack exchange,提问作者Aurélien.AB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:26:02