merge, branches, fetch, push, remotes

Green has the repo “A” on GitHub; Blue wants to upgrade Green’s “A” repo with a new feature.

So let’s break this case down step by step.


Blue goes to “A” repo on Github and fork it. Now Blue has a version of the repo called “A.” Now both Green and Blue have their separated versions of the repo “A.”


Blue needs to clone the repo “A blue GitHub” to his machine; after getting the URL to clone on repo GitHub page, Blue runs the following code:

> git clone GITHUB_URL_A_BLUE

This will clone the repo from GitHub into his local machine, and this local repo has a REMOTE called ORIGIN connecting the local repo “A blue local” to the Blue’s “A blue GitHub”. Blue can PUSH/PULL/FETCH code to ORIGIN because Blue is the owner of the GitHub repo.

If Blue wants to check the remotes from “A blue LOCAL” repo:

> git remote


> git remote -v


Blue wants to check if the “A green GITHUB” repo was updated by Green. So Blue needs to add a new REMOTE connecting the “A blue local” repo to the “A green GitHub” repo. Blue needs to go the “A green GitHub” repo and get the URL of the repo. Blue will call this new remote as UPSTREAM:

> git remote add upstream GITHUB_URL_A_GREEN

Now “A blue local” repo has the following remotes:

ORIGIN(A blue GitHub): Because of this remote point to a repo that belongs to Blue. Blue can PUSH/PULL from this repo.

UPSTREAM(A green GitHub): Because of this remote point to “A green GITHUB” that belongs to Green, Blue can’t PUSH to this repo, but Blue can FETCH/PULL from this repo.


Blue creates a new branch on his local “A blue local” repo to add a new feature to the repo. Blue does this to keep the MASTER branch safe from modifications.

To create a new branch and change to it immediately run the command:

> git checkout -b [name_of_your_new_branch]BLUE WANTS TO CREATE A BRANCH CALLED UPGRADE:> git checkout -b upgrade

5 After finished the upgrade.

After finishing the upgrade, Blue needs to PUSH the “UPGRADE” branch to ORIGIN remote; so Green can see what Blue did.

> git push origin upgrade

After this, Blue is done!

6 Green Starts

Green looked on “A blue GitHub” and wants to upgrade “A green local” with Blue’s upgrade.

So now Green needs to ADD a REMOTE to PULL or FETCH the “A blue GitHub” UPGRADE branch.

> git remote add blue GITHUB_URL_A_BLUE

Now Green is ready to get the “UPGRADE” branch.


With the new remote to “A green local”; Green can finally fetch the blue remote to downloads all the branches without merge it immediately.

> git fetch blue


Now Green wants to merge the “A green local” master branch with the branch “upgrade” from the REMOTE Blue.
First, Green needs to go to the local master branch:

> git checkout master

Then Green runs the following command to merge the branch blue/upgrade into the master.

> git merge blue/upgrade


Green pushes the master branch to ORIGIN/master

> git push origin master





Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Magnets and Unity — how to make an object come to you!

From New Hacker to CUhackit Director

7 Highly Recommended Programming Books for 2017

Tell a Story by Map

Git Guide- The Complete Story

Flutter V.I.P.E.R Pattern Architecture

Why I love Jenkins so much

SQL Many-to-One relationship Derive table

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pedro Fonseca

Pedro Fonseca

More from Medium

How I made Apache Superset a macOS App

SuperChart in MAS

Version Controlling Systems & Databases

Multimodule Projects in Git Part1: Handling Subprojects Using Git Submodule

Setup hot standby PostgreSQL