GitHub Fork Syncronisation

I am struggling to synchronise a fork of https://github.com/KiCad/kicad-symbols in my own GitHub directory.
Can somebody explain how to do this?

step one add the official library as a second remote

git remote add upstream https://github.com/KiCad/kicad-symbols.git

Then you can sync your personal master branch like this:

git checkout master  # switch to the master branch locally
git pull upstream master   # pull upstream changes into your local master branch
git push  # sync your personal github fork with your local changes (therefore with the current official repo)

If you get a merge conflict when pulling from upstream then you damaged your personal master branch. There is a hotfix possible.

git fetch upstream # download state of official repo
git checkout upstream/master # switch to head of master as it is on the official repo
git branch -D master # delete damaged local master
git checkout -b master # recreate master locally in sync with official repo
git push --set-upstream origin master --force # forcefully push this new master to github (force because this changes the history)

If you just want to base a new branch on top of the official repos master then you can also do

git fetch upstream # download state of official repo
git checkout upstream/master # switch to head of master as it is on the official repo
git checkout -b new_branch_name # create the new branch
git push --set-upstream origin new_branch_name # push the new branch to github (ready to go for a pull request)

if you want to check a particular pull request then you can do this

git fetch upstream pull/[number]/head # replace [number] with the number of the pull request
git checkout FETCH_HEAD # this switches over to the top of the pull request
2 Likes

The git push failed with a fatal error
the suggested “git push --set-upstream origin master” worked

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.