We are currently in the process of moving away from master being the default branch, to main being the new default branch. This page still refers to both, but expect that it will eventually refer only to main as the default branch. For instructions to switch from master to main on your local clone/fork, please see the Always Work on a Branch page: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/always-work-on-a-branch#moving-your-local-clone-and-fork-from-master-to-main-3067724-22

Congratulations! Your pull request was approved and merged, and your code is now part of the original project's repo. This means that your fork's main or master branch is now behind the original project's main or master branch. It's now time to update your main or master to match the original project.

The first thing you want to do is return to the main or master branch. If you're unsure which branch you're currently on, type git branch to see a list. The current branch will be highlighted with an asterisk next to it. You should still be in the branch you created. So let's return to main or master.

To check out the main or master branch, enter the following checkout command:

git checkout main

Or:

git checkout master

Next, we're going to utilise the original project remote we created. To get the updates from the remote repo, we're going to use fetch. Remember, fetch grabs the the newest version of the remote repo, but does not merge it into the current repo.

Remember, you named the original project's remote repo with the owner's GitHub ID. You'll use this name when you merge the two main or master branches together. Since I cloned an Adafruit repo, I'll be using adafruit.

To fetch the updated remote, enter the following fetch command, replacing ownerid with the name you assigned to the remote repo:

git fetch ownerid

Now we're going to merge the current data into our local repo. Remember, a merge takes the information from one branch and combines it into another. In this case, it's going to take the current version of main or master from the remote repo and combine it with the main or master branch on your local repo. This will bring you even with the remote main or master, including the changes you submitted.

To merge the remote main or master with your master, run the following merge command, replacing ownerid with the name you assigned to the remote repo:

git merge ownerid/main

Or:

git merge ownerid/master

Those numbers may look familiar. They match the changes from my PR! This will not always be the case. With larger projects, people are constantly submitting changes and the list from this step may be lengthy. Regardless, you're set to move on to the next step - the results aren't important to the process of updating.

Now your local repo is even with the remote repo. Your remote fork on GitHub, however, is not. It does not automatically update when you update locally. So, you must manually push your locally updated main or master to your remote fork. This uses the exact same command format as pushing your working branch did. This time, however, we're pushing the main or master branch.

Remember, you named your remote repo with your GitHub ID. You'll use this to push the updated main or master branch in the same way you did when pushing your working branch.

To update your remote fork on GitHub, type the following push command, replacing yourID with your GitHub ID:

git push yourid main

Or:

git push yourid master

Now the main or master branch on both your local repo and your remote repo are up to date. You're ready to continue working. From here, you can return to your previous branch and update it, or you can create a new branch and start on a new contribution.

Keep in mind, if you step away from a repo for a period of time, you should always update it before creating a branch to work with or you may be working with out of date data. This can lead to conflicts when attempting to merge later. Conflicts can be incredibly frustrating, but are easily avoided if you keep your branches up to date as you go. When it comes time to create your PR, verify that it can be merged automatically before creating it. If it can't, you may have been working with an out of date branch and will need to update it before creating the PR. Don't be afraid to ask for help with this! Sometimes it's a simple fix, other times it's more complicated. We're always happy to help you work through it.

This guide was first published on Jun 29, 2018. It was last updated on Jun 29, 2018.

This page (Staying Up To Date) was last updated on Sep 14, 2020.