I've started playing with Git and have come across the terms "upstream" and "downstream". I've seen these before but never understood them fully. What do these terms mean in the context of SCMs (Software Configuration Management tools) and source code?
Stream – The moving water in a river is called a stream. Upstream – If the boat is flowing in the opposite direction to the stream, it is called upstream. In this case, the net speed of the boat is called the upstream speed. Downstream – If the boat is flowing along the direction of the stream, it is called downstream.
The upstream supply chain includes all activities related to the organization's suppliers: those parties that source raw material inputs to send to the manufacturer. The downstream supply chain refers to activities post-manufacturing, namely distributing the product to the final customer.
What Is the Difference Between Upstream and Downstream in the Oil and Gas Industry? Upstream oil companies are involved primarily with oil discovery, extraction, and production. Downstream oil companies instead deal with refining and delivering petroleum products to consumers.
Something that is moving downstream is moving towards the mouth of a river, from a point further up the river. Something that is downstream is further towards the mouth of a river than where you are.
In terms of source control, you're downstream when you copy (clone, checkout, etc) from a repository. Information flowed "downstream" to you.
When you make changes, you usually want to send them back "upstream" so they make it into that repository so that everyone pulling from the same source is working with all the same changes. This is mostly a social issue of how everyone can coordinate their work rather than a technical requirement of source control. You want to get your changes into the main project so you're not tracking divergent lines of development.
Sometimes you'll read about package or release managers (the people, not the tool) talking about submitting changes to "upstream". That usually means they had to adjust the original sources so they could create a package for their system. They don't want to keep making those changes, so if they send them "upstream" to the original source, they shouldn't have to deal with the same issue in the next release.
When you read in git tag
man page:
One important aspect of git is it is distributed, and being distributed largely means there is no inherent "upstream" or "downstream" in the system.
, that simply means there is no absolute upstream repo or downstream repo.
Those notions are always relative between two repos and depends on the way data flows:
If "yourRepo" has declared "otherRepo" as a remote one, then:
Note the "from" and "for": you are not just "downstream", you are "downstream from/for", hence the relative aspect.
The DVCS (Distributed Version Control System) twist is: you have no idea what downstream actually is, beside your own repo relative to the remote repos you have declared.
Basically:
In term of "flow of data", your repo is at the bottom ("downstream") of a flow coming from upstream repos ("pull from") and going back to (the same or other) upstream repos ("push to").
You can see an illustration in the git-rebase
man page with the paragraph "RECOVERING FROM UPSTREAM REBASE":
It means you are pulling from an "upstream" repo where a rebase took place, and you (the "downstream" repo) is stuck with the consequence (lots of duplicate commits, because the branch rebased upstream recreated the commits of the same branch you have locally).
That is bad because for one "upstream" repo, there can be many downstream repos (i.e. repos pulling from the upstream one, with the rebased branch), all of them having potentially to deal with the duplicate commits.
Again, with the "flow of data" analogy, in a DVCS, one bad command "upstream" can have a "ripple effect" downstream.
Note: this is not limited to data.
It also applies to parameters, as git commands (like the "porcelain" ones) often call internally other git commands (the "plumbing" ones). See rev-parse
man page:
Many git porcelainish commands take mixture of flags (i.e. parameters that begin with a dash '
-
') and parameters meant for the underlyinggit rev-list
command they use internally and flags and parameters for the other commands they use downstream ofgit rev-list
. This command is used to distinguish between them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With