| 2023-09-11

GitHub Flow - Part 1

    Introduction

    Overview of GitHub Flow

    Welcome to the GitHub Flow Code-Along. GitHub Flow is a lightweight, branch-based workflow that supports teams and projects where deployments are made regularly. This workflow encourages continuous delivery and integrates well with modern deployment techniques while retaining a simple and efficient process.

    Here is a quick overview of the GitHub Flow process:

    1. Fork: Create a copy of a github repository.
    2. Clone: Get a local copy of the forked repository.
    3. Branch: Create a new branch off the main branch to work on changes.
    4. Edit: Make changes in the local environment.
    5. Commit: Save changes locally with a descriptive message.
    6. Push: Upload the branch and changes to the remote forked repository.
    7. PR (Pull Request): Open a pull request from the forked repository to the original project to propose the changes.
    8. Review: Review the changes, possibly discussing improvements or adjustments.
    9. Merge: Upon approval, the changes are merged into the main branch of the original repository.
    10. Deploy: The changes are implemented in a production environment, if applicable.

    When to Use GitHub Flow

    Utilize GitHub Flow for projects that require continuous delivery and for teams looking for a straightforward and agile workflow. It is excellent for both small and large teams, promoting collaboration through pull requests, code reviews, and much more.

    Pre-requisites

    Before we get started, ensure that you have the following ready:

    • A GitHub account (create one here)
    • Git installed on your local machine (find the installation guide here)
    • A text editor (like Visual Studio Code, Sublime Text, or any other)
    • Basic knowledge of Git and GitHub

    Part 1: Setting Up Your Workspace

    Forking the Repository

    As a practical start, we will work with the First Contributions repository. Forking creates a personal copy of another user's repository. This allows you to experiment with changes without affecting the original project. Head over to the First Contributions repository and follow these steps to fork it:

    1. Click on the Fork button at the top right corner.
    2. Choose where to fork the repository (if you are part of organizations).

    Your fork retains a link to the original repository, enabling you to submit a pull request to contribute your changes upstream.

    Cloning Your Fork Locally

    After forking the First Contributions repository, the next step is to clone it to work locally on your system. Use the following command to clone your fork, replacing YOUR-USERNAME with your GitHub username:

    git clone https://github.com/YOUR-USERNAME/first-contributions.git
    
    bash

    Setting Up the Upstream Remote

    To keep your fork synchronized with the original First Contributions repository, set up an "upstream" remote. Navigate to your local repository's directory and run the following command:

    git remote add upstream https://github.com/firstcontributions/first-contributions.git
    
    bash

    Verify your remotes with this command:

    git remote -v
    
    bash

    You should see the URLs for both "origin" (your fork) and "upstream" (the original repository).

    Now, you're all set with your workspace! Stay tuned for the next part of the series where we will delve deep into creating and managing branches in GitHub Flow.


    In the next article, we will walk through the steps of creating a new branch, working on your feature, and the entire process up until merging your changes into the main branch. This series aims to equip you with all the skills necessary to collaborate effectively on open-source projects using GitHub Flow. Happy coding!


    Thanks for reading. If you enjoyed this post, I invite you to explore more of my site. I write about web development, programming, and other fun stuff.