×

Git Upstream and Downstream

Git Upstream and Downstream

Upstream and downstream in Git are usually defined with the context of a repository. In general terms, upstream refers to the location through which we clone the repository. The term downstream is defined as the process of integrating our work with other works. These two methods are not just restricted to Git repositories, but they also play a crucial role in the project.

Let’s discuss this in detail.

As the name suggests, upstream and downstream define the flowing nature of the activities we carry while working on a project. It means that these are remote activities having time and history constraints. Concerning the subject cited above, if a remote repository is upstream or downstream, the downstream repository is pulled from the upstream repository. This gives us an idea that the data flow is downstream by default.

There is an ambiguity that upstream is defined in time while downstream is defined in history and vice-versa. One better way to understand this is by using parent/child terms to get time and history. Let us understand these terms by implementing them.

Git Upstream and Downstream

The above diagram defines the workflow of both this stream and how they work. The picture is just for reference. It will be clear once we get our hands dirty by executing commands necessary for upstream and downstream.

Note: Upstream is always local while downstream is remote.

Upstream

As we know that upstream and downstream constitute local and remote nature. The upstream is channeled through a remote server. For this, we need to set upstream and check if the remote server is present to carry out or not. The commands below can be helpful.

If we type -set upstream, it throws an error like

error: failed to push some refs to 'https :< remote repository Address>

Since we have not defined the remote server, we need to check it the through the following commands.

$ git remove -v

This command will show the origin of the remote repository on GitHub. This shows the remote server name.

$ git branch -a

This command gives the branch list with the repository. Now you need to push the changes you have made in the repository to the remote server and make it default and to do this, type the following command.

$ git push --set-upstream origin master

This command will set the master branch to default remote branch. The console now shows that everything is up to date. Now, we can also set the default remote branch and view them by using the below commands.

$ git branch --set-upstream-to origin master
$ git branch -vv

Downstream

Downstream works in association with upstream. We again need to establish a remote server since the upstream is a locally stored repository while downstream is the default flow of the data.

Type the following commands for establishing server if the errors show something like this.

error: failed to push some refs to 'https :< remote repository Address>

We then need to navigate or map branches and to do that we type the following commands.

 $ git map-branches
 origin/master
   cool_feature
     subfeature
   fixit
     frozen_branch 

After typing this commands, we need to navigate downstream in order to fetch the branches, and to do this we type the following command.

$ git nav-downstream

Previous HEAD position was beec6f4 Make ReflectorImpl use mailboxes

 Switched to branch 'cool_feature'
 Your branch is ahead of 'origin/master' by 4 commits.
   (use "git push" to publish your local commits)
 Please select a downstream branch
   0. cool_feature
   1. fixit
 Selection (0-1)[0]: 0 

We need to map the branches through the following command.

 $ git map-branches
 origin/master
   cool_feature *
     subfeature
   fixit
     frozen_branch 

The final step is to downstream the branch and re-map and check. We do this by typing the following command.

 $ git nav-downstream
 Switched to branch 'subfeature'
 Your branch and 'cool_feature' have diverged,
 and have 2 and 1 different commits each, respectively.
   (use "git pull" to merge the remote branch into yours)
 $ git map-branches
 origin/master
 cool_feature
     subfeature *
   fixit
     frozen_branch 

Let us now discuss what the workflow of downstream states.

Whenever a user makes changes, he/she may want to send the changes back to the upstream so that everyone associated in a team who is working on the repository can pull from the same source and mark reflected changes. This comes with an issue that mostly the same changes can reflect all the members in a single workspace rather than the technical requirement of the source control. Therefore, to submerge these changes into the main project, we downstream them to track the divergent changes in the phase of development.

Also, the package or release managers rectify the changes made by navigating across the submitted changes to the upstream branches thus they send all the changes so that the developers need not adjust the source or keep track of changes. This resolves the issue of sending the changes back to upstream again in the next release.


Related Topics

Git Cherry-Pick

Git Cherry-Pick In Git, the cherry-pick command is used to make the target commit changes and place them on the HEAD of the currently checked-out branch. It is done to either...

3 minutes read.

Terminologies in Git

Terminologies in Git Git is a tool that covered vast terminology and jargon, which can often be difficult for new users or learners. Let's have a look at the commonly used...

4 minutes read.

Git Ignore

Git Ignore: In general terms, a gitignore file is used to specify the intentionally untracked files that Git shout ignore. It doesn't affect the other files as they are already...

3 minutes read.

Git gc

Git gc Overview The abbreviation of gc is 'Garbage Collection'. In Git, there is a command used to maintain the repository which is git gc. When you execute this command, you...

4 minutes read.

Python wx module

Python wx module Introduction Python provides us a wxpython module which we usually call as Python wx module. The wxpython module is allow us to create a very high functional GUI...

4 minutes read.

Git Blame

Git Blame Overview The blame command is an extensively used utility tool for configuring various options and troubleshooting. It is a high-end sophisticated and versatile tool for displaying the metadata that...

4 minutes read.

Git Workflow Releasing Management

Git Workflow2 Releasing Management The steps between from collaboration to release are going to start at different points within the development process for each team. Generally, you would not want to use...

3 minutes read.

Git Revert

Git Revert The term revert in Git is generally used to rollback changes. The operation involves getting the previously modified versions or simply applying the changes back to where they previously...

4 minutes read.

Github Version Control System

As discussed earlier, Github is a decentralized open-source version control software independently owned and managed by Microsoft. It is free and has tremendous features that work in close integration with...

5 minutes read.

How to Install Git on Windows?

How to download Git and Installation Guides for Windows step by Step? To carry out operations with Git, we need to install it on our computer. Even if we have already...

3 minutes read.

Git Version Control Comparison

Version Control Comparison: Choosing the best version control framework is quite a difficult task for most of the users because of available plenty options. While choosing the right version control...

4 minutes read.

Git reflog

Git reflog: The Git reflog or Reference Logs is a rare command that is used to record logs when certain branches along with references were once updated in the local...

4 minutes read.

Git bisect

Git bisect Overview The bisect command in Git is a utility tool that lets you identify an offending commit. Consider an instance where you came across a bug in your source...

3 minutes read.

Git submodule

Git submodule Overview Git submodules allow you to keep a git repository as a subdirectory of another git repository. Git submodules are simply a reference to another repository at a particular...

4 minutes read.

Git Workflow

Git Workflow: Being one of the best version control systems for your projects, Git is not just about handling projects but also to collaborate and release management. It gives you...

3 minutes read.

Git Upstream and Downstream

Git Upstream and Downstream Upstream and downstream in Git are usually defined with the context of a repository. In general terms, upstream refers to the location through which we clone the...

4 minutes read.

Git Reset

Git Reset: The reset command in Git is quite complex and a great tool to undo changes. There are some strict invocations or forms of undoing changes in Git. These...

4 minutes read.

Git Squash

Git Squash How to Squash? The squash command in Git is used to suppress or subdue the previous commits into one unit. It is quite interesting to note that squash is not...

3 minutes read.

Git Tutorial

Git tutorial Overview: Git was created by Linus Torvalds in 2005. Today, Git is a Microsoft-owned company after the approval of the CEO of the EU. In this tutorial, we will...

4 minutes read.

Git diff

Git diff Overview The diff command in Git is generally a function that inputs two data sets and rolls out the changes made between them. It is a multitasking tool that...

3 minutes read.