Skip to main content

Setup and Pull Upstream Changes

· One min read

Step 1: Pull upstream changes

git pull --rebase upstream master

The --rebase option places your changes on top of the latest commit without merges.

Step 2: (Optional) Merge your commits into 1 commit

git reset --soft upstream/master

This command will "undo" all your commits, but won't change the files. So you can commit all your changes in a single commit.

git commit -a

Step 3: Check & test your changes

To show the changes use a GUI like the built-in gitk, Sourcetree, TortoiseGit or Tower (paid), etc.

Step 4: Push

git push will throw an error, push with "-f"

git push -f origin master

Additional information

The command to add a remote is:

git remote add upstream git://[username]/[project].git

You can also also pull from a direct URL:

git pull --rebase git://[username]/[project].git

But then you'll need the hash of the latest upstream commit instead of "upstream/master" in the other steps.