This post was most recently updated on November 30th, 2020.
Reading Time: 2 minutes.This is one of those “note to self” -kind of entries. This workflow is probably so natural to a lot of you all, that you won’t need to ever google it – but since I don’t do that much development with the full “fork – clone – branch – submit pull request” -process (whihc is really typical with GitHub and I guess Open Source in general), I always need to look up the instructions on how to add pull any changes from the original repository to yours.
I even need to do that often enough, that I wanted to document it somewhere where I can find it easily. Like my blog :)
So, here goes:
Synchronizing your local changes with the upstream repository
There’s a number of steps – see below.
Time needed: 10 hours.
How to synchronize your forked and local repositories with the original one on GitHub?
- Open a command prompt
Open Git Bash or similar command prompt with git executable available.
- Change the current working directory to your local project.
This can be done running the following command:
cd [your_project_directory]
- Change to your desired branch
You’ll probably want to merge to your main or master – so make sure it’s checked out!
You can change it from GitHub Desktop (if you’re using it), or you can run this:git checkout [branch_name]
- Configure the origin as a remote repository
This needs to be done to enable you to fetch the new commits from it. You can verify if it already is by running this:
git remote -v
If it isn’t, then run this:git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
- Sync your local repository with the upstream (the original one)
Run the following command in command prompt:
git fetch upstream
- Perform merge
Run this:
git merge upstream/master
If you get a text editor window in your bash, that’s just Vi asking for your commit comment for your merge. Don’t have to enter anything, just write “:wq” and you should be good.
If you’re on Windows, install the latest git version and it’ll actually let you set Visual Studio Code as the default text editor. - Push your local changes to your repository
“Your local changes” = your merge from upstream = all of the new stuff from the original repository on GitHub.
You can perform this step in GitHub Desktop, or by running this in your comsole prompt:git push
And now you should be good.
References
- https://help.github.com/articles/syncing-a-fork/
- https://help.github.com/articles/configuring-a-remote-for-a-fork/
- How to fix “System.IO.FileSystem: Could not find a part of the path \AppData\Local\AzureFunctionsTools\Releases\3.17.0\workers. Value cannot be null. (Parameter ‘provider’)” when running Azure Functions locally? - January 12, 2021
- How to nuke the Identity Cache in Visual Studio? - January 11, 2021
- Fixing unexpected Microsoft.AspNetCore package errors after a dependency update - January 6, 2021