Skip to content

Keeping Current with Upstream

MissyM2 edited this page Apr 23, 2020 · 2 revisions

CFPB is constantly updating the master branch of their upstream cfgov-refresh repo. I (Mike Green) have been regularly updating Raft's fork with the latest changes from (CFPB) upstream once a week on Mondays. I generally also get us in sync with (CFPB) upstream whenever I'm about to submit an internal PR. This is the procedure I've been following:

First-time Setup

If you haven't done it already, add CFPB's repo as a remote in your local clone:

git remote add upstream [email protected]:cfpb/cfgov-refresh.git

Pulling from Upstream

Grab the latest commits on CFPB's master branch, add them to ours, and push them up to our fork.

git checkout master
git pull upstream master
git push origin master

Next, checkout each mainline dev branch and merge master in. I'll use the My Money Calendar branch as an example.

git checkout my-money-calendar
git merge master

You may need to resolve conflicts in order for the merge to finish cleanly. If that happens, edit each file with conflicts (VS Code has a nice interface for this), save, git add it, and when you're done run git merge --continue.

At this point, before pushing up to origin, make sure that your app still runs and builds. If you haven't pushed yet, you've still got a copy of your app that works sitting up on GitHub, so wait until you're sure you don't have to wipe out everything you've just done locally before burning the ships on the beach. Here's what I do to test:

# Run any pending migrations. CFPB may have made database schema changes that need to be applied to your local DB:
cfgob/manage.py migrate

# start up the server
./runserver.sh

# wipe out all frontend files and do a full rebuild:
gulp clean && gulp build

Then try to load up your app and make sure it's working. If it looks good...

git push origin my-money-calendar

Applying latest changes to WIP feature branches

Note: Only do one of the following - rebase, or merge.

Option 1: Rebase

If nobody else is working on your feature branch alongside you, or if you haven't yet pushed it up to GitHub, you can do a rebase to apply upstream changes more cleanly than a merge:

git rebase my-money-calendar

You may need to repeatedly resolve conflicts if you go this route, because it will apply all of CFPB's commits to master, then apply your branch's commits on top of them. Each commit carries the potential for conflicts, but your revision history looks much cleaner when it's done.

When you're done, push. If you've already pushed the branch to GitHub before rebasing, you'll need to use the --force flag to overwrite the branch with your new rebased version.

Option 2: Merge

Merging is quicker and squishes all of CFPB's upstream changes and yours into a single merge commit. There's only one set of conflicts to resolve, if you encounter any, but it's more difficult to reason about the branch's revision history afterwards.

git merge my-money-calendar

Then push, and you're done.

Clone this wiki locally