Home » Git Upstream and Downstream

Git Upstream and Downstream

by Online Tutorials Library

Upstream and Downstream

The term upstream and downstream refers to the repository. Generally, upstream is from where you clone the repository, and downstream is any project that integrates your work with other works. However, these terms are not restricted to Git repositories.

There are two different contexts in Git for upstream/downstream, which are remotes and time/history. In the reference of remote upstream/downstream, the downstream repo will be pulled from the upstream repository. Data will flow downstream naturally.

In the reference of time/history, it can be unclear, because upstream in time means downstream in history, and vice-versa. So it is better if we use the parent/child terms in place of upstream/downstream in case of time/history.

Git set-upstream

The git set-upstream allows you to set the default remote branch for your current local branch. By default, every pull command sets the master as your default remote branch.

Sometimes we are trying to push some changes to the remote server, but it will show the error like “error: failed to push some refs to ‘https :< remote repository Address>.” There may be the reason that you have not set your remote branch. We can set the remote branch for the local branch. We will implement the following process to set the remote server:

To check the remote server, use the below command:

It will result as follows:

Git Upstream and Downstream

The above output is displaying the remote server name. To better understand remote server, Click here. Now, check the available branches, run the below command:

It will result as follows:

Git Upstream and Downstream

The above command will list the branches on the local and remote repository. To learn more about branches, click here. Now push the changes to remote server and set the particular branch as default remote branch for the local repository. To push the changes and set the remote branch as default, run the below command:

The above command will set the master branch as the default remote branch. To better understand the origin master click here.

Consider the below output:

Git Upstream and Downstream

In the given output, everything is up to date with the remote branch.

We can also set the default remote branch by using the git branch command. To do so, run the below command:

To display default remote branches, run the below command:

Consider the below output:

Git Upstream and Downstream

The above output is displaying the branches available on the repository. We can see that the default remote branch is specified by highlighted letters.


Next TopicGit Checkout

You may also like