Skip to content

Workflows

Git Workflows

Forking Workflow

GitHub Forking Workflow

Adding an Upstream Repo

  • To add the upstream repo (the repo you originally forked from) to your remote repos do the following:

    • Open terminal and navigate to your local git repository

      1
      cd ~/Development/<CLONED REPO DIR>
      
    • Run the remote add command

      1
      git remote add upstream <GitHub HTTP URL TO ORIGINAL REPO>
      
    • Verify that the upstream was added.

      1
      git remote -v
      

Updating My Fork (CLI) Version

  • Open terminal and navigate to your local git repository

    1
    cd ~/Development/<PROJECT DIR>
    
  • Checkout the feature branch that holds the changes you desire to merge

    1
    git checkout <BRANCH NAME>
    
  • Confirm your local repo knows about the upstream repo (the repo you originally forked from). If you see only remote repos from your GitHub, you must add the upstream.

    1
    git remote -v
    
  • Fetch changes made to the upstream while you were working on your feature. If there were changes, you will see them displayed.

    1
    git fetch upstream
    
  • Merge the remote upstream changes into your local branch (remember you already checked out your local feature branch).

    1
    git merge upstream/master
    
  • Now upload those changes to YOUR remote origin (i.e. your GitHub fork).

    1
    git push origin
    
Warning

If you’re working with feature branches (which we are!) you may need to push your changes from YOUR local feature branch to YOUR remote origin feture branch like so.

1
    git push origin <LOCAL BRANCH NAME>:<ORIGIN BRANCH NAME>
  • Now our forked (origin) remote repository on GitHub is up to date with the original (upstream) repository we forked from!
  • Finally, from GitHub, go to the branch you just pushed in YOUR GitHub account, and issue a Pull Request to the Semester Branch on the upstream!

Clone Local

  • Once you have forked the upstream repository to your GitHub account, you will need to clone it to your local computer.
    1
    git clone <GIT SSH or HTTP URL FOR REPO>
    

GitFlow Workflow

Note

This workflow is very typical within a large development organization such as Amazon and Google, though there are other workflows! I am not focusing on it because we will be using the forking workflow.

GitFlow Workflow

Short GitFlow Explanation

  • Master: Stable branch, that deploys direct to production.
  • Develop: Unstable branch, and all feature branches will be pushed here.
  • Feature: Check out from Develop branch, and push changes back to it.
  • Hotfix: Check out from Master, push changes to Master AND Develop.
  • Release: Semi-stable, ready to test and release, following a few bug-fixes. Checkout from Develop and push to both Master and Develop.