Git Town Documentation

repository·main·Indexed 24 days ago

https://github.com/git-town/git-town

A CLI tool that automates Git workflows, focusing on branch management, synchronization, and stacked changes. It supports workflows such as Git Flow, GitHub Flow, GitLab Flow, and trunk-based development, providing specialized support for mono-repos and dependent branch stacks.

Tokens
60.8K
Snippets
220
Records
593
Agent score
83%

What's inside Git Town

  1. Overview of Git Town features

    main
    Git Town automates the creation, synchronization, shipping, and cleanup of Git branches. It is compatible with popular workflows such as Git Flow, GitHub Flow, GitLab Flow, and trunk-based development. It also provides specialized support for mono-repos and stacked changes.
  2. Overview of Git Town

    main

    Git Town is a high-level CLI that provides a reusable implementation of Git workflows. It is designed to replace manual, error-prone Bash scripts with engineered commands for common version control scenarios.

    Key capabilities include:

    • Creating various branch types.
    • Keeping branches in sync.
    • Compressing, reviewing, and shipping branches efficiently.
    • Support for mono-repos and stacked changes.

    Git Town is compatible with several branching models, including:

    • GitHub Flow
    • Git Flow
    • GitLab Flow
    • Trunk-based development
    • Direct commits to the main branch.
  3. Understand Git Town branch types

    main

    Git Town categorizes branches into two primary groups: Long-lived (perennial) and Short-lived.

    Long-lived branches

    Also called perennial branches, these are branches that exist indefinitely (e.g., main, master, development). The main branch is a special perennial branch that serves as the default base for cutting and merging short-lived branches.

    Short-lived branches

    Used for active development, these are typically created from and merged back into a perennial branch. They are further categorized by ownership:

    Owned by you:

    • feature branch: Active work branches that Git Town keeps up to date.
    • prototype branch: Early-stage branches not yet ready for a shared remote.
    • parked branch: Branches you own but are not actively working on; Git Town does not sync these to reduce noise.

    Owned by others:

    • contribution branches: Branches owned by others that you are contributing code to (no lifecycle events like sync or ship are performed).
    • observed branches: Branches owned by others that you review but do not contribute code to.
  4. Understand the Git Town execution and undo frameworks

    main

    Git Town operates using an interpreter-based execution model and a snapshot-based undo mechanism to ensure reliability and recoverability.

    Execution Framework

    Git Town commands are not hard-coded scripts; they are programs composed of Git-related opcodes executed by an interpreter.

    • Self-modifying programs: Opcodes can inspect the repository state at runtime and inject new opcodes, allowing the program to adapt to the environment.
    • Terminate and Resume: If an operation requires user intervention (e.g., resolving a conflict), the interpreter persists the current runstate to disk and exits. After the user resolves the issue in their shell, restarting Git Town loads the runstate and resumes execution from where it left off.

    Undo Framework

    To revert changes made by a command, Git Town:

    1. Compares snapshots of the Git repository from before and after the command execution.
    2. Determines the specific changes made.
    3. Generates a new program consisting of opcodes that reverse those changes.
    4. Executes the reversal program via the interpreter.
  5. Git Town compatibility and team usage

    main

    Compatibility

    Git Town is designed to be compatible with other Git tools and the broader Git ecosystem.

    Team Requirements

    Your entire team does not need to use Git Town to benefit from it. Even as a solo user, Git Town provides value by automating standard Git commands that are typically required to maintain a tidy repository and keep branches in sync.

  6. Understand Git Town branch types and syncing behavior

    main

    Git Town uses specific branch types to determine how git town sync or git town sync --all behaves. Each type has unique rules for syncing with parents, tracking branches, and whether the branch can be 'shipped'.

    branch typedescriptionsyncing behaviorship
    mainprimary development branchsync with origin, pull from upstreamno
    perenniallong-lived branch (e.g., develop, staging)sync with originno
    featurenormal feature branchsync with parent and tracking branchyes
    prototypework-in-progress featuresync with parent, don't push to trackingyes
    parkedinactive feature branchno syncingyes
    contributionsomeone else's branch, you share changessync with trackingno
    observedsomeone else's branch, you don't share changespull from trackingno
  7. Supported Git branching models in Git Town

    main

    Git Town is designed to be flexible and supports a wide range of branching strategies, including:

    • GitHub Flow
    • Git Flow
    • GitLab Flow
    • Trunk-based development

    It is also compatible with workflows where commits are made directly to the main branch.

  8. Compare Git Town with git-flow

    main

    While git-flow is a specialized extension focused on providing opinionated support for the specific Git Flow branching model, Git Town is model-agnostic. Git Town focuses on:

    • Syncing team work across branches.
    • Keeping repositories tidy by cleaning up old branches.

    You can use Git Town alongside git-flow if your workflow requires both.

  9. Configure Git Town preferences at different levels

    main

    Git Town uses a hierarchical configuration system. Settings are applied in the following order of precedence (from lowest to highest):

    1. Default settings: Built-in defaults.
    2. System-specific settings: Settings specific to the operating system/environment.
    3. Environment variables: Overrides all other settings.
    4. Configuration file: Team-wide settings applied to all users in a repository.
    5. Git metadata (Global): Developer-specific settings for all repositories on a machine.
    6. Git metadata (Local): User and repository-specific settings that take precedence over all others.
    7. CLI flags: The highest priority; overrides everything else.
  10. Understand Git Town branch lineage configuration

    main

    Git Town uses specific configuration entries to track the lineage of branches. These entries follow the pattern git-town-branch.<branch>.parent=<branch>, where <branch> is the name of the branch and its parent.

    Note: You do not need to manually manage or edit these entries. Git Town automatically maintains this lineage as it creates and removes feature branches.

  11. Verify connector interface parity with lint_cached_connectors

    main

    The linter automates the verification of interface implementations by following these steps:

    1. Parsing Go source files to identify connector pairs.
    2. Extracting interface implementations from type check comments (e.g., var _ forgedomain.ProposalFinder = apiConnector).
    3. Comparing the interfaces implemented by the cached version against the uncached version.
    4. Reporting any discrepancies where a cached connector is missing an interface implementation present in the uncached version.