Working with upstream repos
Keeping your downstream repo up-to-date
A downstream repository (aka a “*fork*”) maintainer commonly needs to stay current with upstream work (aka “original”). The case is development continues on the
upstream repo while you work on your own
origin fork. You want to
fetch the upstream changes and apply them to your
origin so you don’t make conflicts.
The following steps allow you to achieve this on the command line in a local git repository.
Add the Remote Upstream Repository
This step defines the upstream repository of your fork. First is the syntax followed by an example.
git remote add <any_name_you_choose> [Upstream git URL] git remote add upstream https://github.com/QubesOS/qubes-doc.git
Fetch the Upstream Branches
git fetch <the_name_you_chose_earlier> git fetch upstream
Merge Upstream Changes into your Downstream Repository
From your master branch, use the following merge command to merge the upstream master branch changes into your local source:
git checkout origin/master git merge upstream/master
You then can either merge into the branch you were previously working on or start a new branch. Since starting a new branch is easy, this sample is merging the
master branch into the
git checkout origin/develop git merge origin/master
- You fork from the
cloneand then create a local copy on your computer.
- You create a new branch
branch-1off of the
masterbranch to do your work on.
pushthose commits from
branch-1to your own
- You then create a pull request with the
upstreamrepo into the
- Your pull request is
masterbranch and development continues on the
masterbranch past your local and
- You then have to
upstreamrepo before you continue your work to avoid conflicts
- You then
upstreamchanges to your