apurbabehera / evershop

🛍️ NodeJS E-commerce Platform
https://evershop.io/
GNU General Public License v3.0
0 stars 0 forks source link

Explore Git Branching Workflows #6

Open apurbabehera opened 4 months ago

apurbabehera commented 4 months ago

Explore the most popular Git Branching workflows:

Research and try out out each workflow and answer the following questions for each of the 4 workflows:

Finally, based on your research and analysis select the workflow that you will implement for the case study.

ManoharMP3 commented 4 months ago

A detailed overview of Git Branching Workflows

Centralized Workflow

The Centralized Workflow is a simple and straightforward Git branching strategy that is well-suited for small teams or projects with minimal branching needs. -Main Branch: Only one main branch (e.g., master or main) for development. -Direct Commits: Developers work directly on the main branch. -Pulling Changes: Developers pull changes before starting new work. -Code Review: Optional code review before pushing to main. -Continuous Integration: CI ensures code quality before commits. -Release Preparation: Tag main branch for releases. -Deployment: Deploy tagged versions to production. Use Cases of Centralized Workflow: 1.Small teams or projects where a more complex branching model isn't necessary. 2.Projects where everyone needs to be aware of all changes happening in the codebase in real-time.

Feature Branch workflow

The Feature Branch Workflow is a branching strategy that promotes parallel development by creating separate branches for each feature or task. -Main Branch: One main branch (e.g., master). -Feature Branches: Developers create branches for each feature/task. -Development: Work is done on feature branches. -Commit Changes: Developers commit changes to feature branches. -Pull Changes: Optional syncing with main branch. -Code Review: Pull requests for merging into main branch. -CI: Tests run on pull request changes. -Merge to Main: After review and tests pass, feature branches are merged into main. Use Cases of Feature Branch workflow: 1.Projects with multiple developers working on different features concurrently. 2.Projects where code quality and collaboration are essential.

Gitflow Workflow

The Gitflow Workflow is a branching strategy that emphasizes a structured approach to managing branches and releases. --Branching Model: Uses separate branches for different stages of development: -master: Represents production-ready code. -develop: Main integration branch for ongoing development. -feature: Branches off develop for new features. -release: Prepares releases for final testing. -hotfix: Fixes critical issues in production. --Release Management: Formal release process with dedicated release branches for final testing and preparation before merging into master. --Version Control: Strict version management with clear branching, tagging, and merging conventions. --Complexity: More complex than some other workflows due to multiple branches and strict release management process. Use Cases of Gitflow Workflow: 1.Projects with scheduled releases and a need for strict version control. 2.Projects with multiple developers working on different features concurrently, requiring a structured branching model to manage changes effectively.

Forking Workflow

The Forking Workflow is a Git branching strategy commonly used in open-source projects with multiple contributors. -Main Repository: Controlled by project maintainers. -Forking: Contributors create personal copies (forks). -Development: Work in forks' feature branches. -Pull Requests: Changes proposed via PRs. -Code Review: Facilitated by PRs. -Integration: Approved changes merged into main repo. Use Cases of Forking Workflow: 1.Open-source projects with a large number of contributors. 2.Projects where strong isolation between contributors' work is necessary to prevent conflicts and maintain code quality.

As per the case study described, where the development team is facing challenges related to code quality, frequent releases, and manual processes, the most suitable Git branching workflow would be the Feature Branch Workflow. This choice aligns with the need for collaboration, code isolation, and flexible release management, which are essential for addressing the issues faced by the development team. "The Feature Branch Workflow enables parallel development, facilitates code review, and ensures that changes are thoroughly tested before being merged into the main codebase. Additionally, it promotes agile development practices, which can help improve the overall efficiency and quality of the development process."

ManoharMP3 commented 4 months ago

What is the benefit of the workflow?

The Feature Branch Workflow offers several benefits:

  1. Parallel Development: Allows multiple developers to work on different features simultaneously without interfering with each other's work. Each feature is developed in its own isolated branch, minimizing conflicts.
  2. Isolation: Features are developed in dedicated branches, reducing the risk of conflicts and regressions in the main codebase. This isolation ensures that changes can be thoroughly tested before being merged into the main branch.
  3. Code Review: Facilitates code review process through pull requests. Changes are reviewed by team members or reviewers before being merged into the main branch, ensuring code quality and promoting collaboration.
  4. Flexibility: Provides flexibility in managing features and releases. Features can be developed independently and merged into the main branch when ready, allowing for a more flexible and agile development process.
  5. Clear Versioning: Each feature branch represents a specific feature or task, making it easier to track changes and understand the development history of the project.
  6. Stable Main Branch: Maintains a stable main branch (e.g., master or main) containing production-ready code. Features are only merged into the main branch after they have been thoroughly tested and reviewed, ensuring the stability of the main codebase. Overall, the Feature Branch Workflow promotes collaboration, code quality, and flexibility in software development.

Which use case does it solve?

The Feature Branch Workflow is particularly effective in addressing the following use cases:

  1. Parallel Development: When multiple developers need to work on different features concurrently without interfering with each other's work.
  2. Code Isolation and Testing: It ensures that changes for each feature are developed in isolated branches, allowing for thorough testing before integration into the main codebase. This reduces the risk of conflicts and regressions.
  3. Collaboration and Code Review: It facilitates collaboration among team members by providing a structured approach to code review through pull requests. Developers can review each other's code changes before merging them into the main branch.
  4. Flexible Release Management: It allows for flexible feature development and release management. Features can be developed independently in feature branches and merged into the main branch when ready for release. This promotes agility and adaptability in responding to changing project requirements.
  5. Version Control: In projects where maintaining a clear version history and understanding the development timeline of features are important for tracking changes and managing releases effectively.
ManoharMP3 commented 4 months ago

If each of the 5 team members has forked the team repository, made changes in their own forked repositories, and now wants to contribute those changes back to the main team repository, they can follow these steps to submit their contributions via pull requests:

  1. Ensure Forks are Up-to-date: Before making any changes, it's a good practice to ensure that their forked repositories are up-to-date with the latest changes from the main team repository (upstream).

    # Add the upstream repository as a remote
    git remote add upstream <URL_of_team_repo>
    
    # Fetch the latest changes from the upstream repository
    git fetch upstream
    
    # Merge changes from the upstream repository into their local master branch
    git checkout master
    git merge upstream/master
  2. Create a Feature Branch: Each team member should create a new feature branch in their local repository to work on their changes.

    git checkout -b my-feature-branch
  3. Make Changes and Commit: Make the necessary changes to the codebase in their local repository and commit those changes to their feature branch.

    git add .
    git commit -m "Description of the changes made"
  4. Push Changes to Forked Repository: Push the changes to their forked repository on the remote server.

    git push origin my-feature-branch
  5. Create Pull Request: After pushing the changes to their forked repository, each team member can create a pull request (PR) on the main team repository from their feature branch to the appropriate branch (e.g., develop).

  6. Review and Merge: Team members and project maintainers can review the pull requests, provide feedback, and discuss any necessary changes. Once the changes are approved, they can be merged into the main team repository.

By following these steps, each team member can contribute their changes back to the main team repository effectively through pull requests. This process ensures that contributions are reviewed and integrated into the main codebase in a controlled manner.