Version Control (github.png)

Purpose:

The version control system (VCS) employed for the aispec project is GitHub, facilitating collaborative development, code management, and tracking of changes throughout the project’s lifecycle.

Key Concepts:

  • Repositories: A repository (repo) serves as the central storage location for the entire project’s codebase, including its history.
  • Branches: Branches enable parallel development by creating independent copies of the main codebase. This allows developers to work on features or bug fixes without affecting the main codeline.
  • Commits: Each change made to the codebase is recorded as a commit, accompanied by a descriptive message detailing the changes introduced. Commits form the chronological history of the project.
  • Pull Requests: Pull requests (PRs) allow developers to propose changes to the main branch. These requests are reviewed by other team members before being merged into the main codebase.

Workflow:

  1. Forking: Developers typically create a personal fork of the aispec repository to work on their changes.
  2. Cloning: Once forked, developers clone the forked repository to their local machine for local development.
  3. Branching: Before making changes, developers create a new branch from the main branch (usually main) to isolate their work.
  4. Committing: After making changes, developers commit their changes to the local branch, providing descriptive commit messages for clarity.
  5. Pushing: Changes from the local branch are pushed to the remote forked repository.
  6. Pull Request: Once changes are ready for review, a pull request is created on the main repository, aiming to merge the changes into the main branch.
  7. Review and Merge: The pull request undergoes review by other team members. After approval, the changes are merged into the main branch.

Commands:

  • git clone: Clones a repository from GitHub to your local machine.

    git clone https://github.com/helixml/aispec.git
              
  • git branch: Manages branches.

    # Create a new branch named 'feature-x'
              git branch feature-x
              
              # List all branches
              git branch
              
              # Switch to a branch named 'feature-x'
              git checkout feature-x
              
  • git add: Stages files to be included in the next commit.

    git add . # Stages all changes in the working directory
              git add filename # Stages a specific file
              
  • git commit: Creates a commit with staged changes.

    git commit -m "Fix: Issue #123 - Resolved bug in function X" # Commits changes with a message
              
  • git push: Pushes local branch changes to the remote repository.

    git push origin feature-x # Pushes the 'feature-x' branch to the 'origin' remote
              
  • git pull: Fetches changes from the remote repository and merges them into the local branch.

    git pull origin main # Fetches and merges changes from the 'main' branch on the 'origin' remote
              

Best Practices:

  • Use descriptive commit messages.
  • Keep commits focused and atomic (addressing a single issue).
  • Review code before pushing changes.
  • Utilize pull requests for collaboration and review.
  • Keep your local branch up to date with the main branch.
  • For larger projects, consider a branching strategy (e.g., Gitflow).