How to sync your forked repo with original Repo in Github Desktop
Asked Answered
O

2

31

Please Read this before marking as Duplicate

I know there is a solution for CMD at https://mcmap.net/q/13852/-how-do-i-update-or-sync-a-forked-repository-on-github but i asked for GitHub Desktop, If you can't answer then dont mark as Duplicate

I am new to development, I hear about Git and GitHub learn very basics then I downloaded GitHub Desktop After a while I found a great Open Source project I forked it and cloned the forked Repo in my Github Desktop. I improved some features in and and Synced my local Repo with my GitHub forked Repo, after that I did a Pull Request My addition was accepted and merged into original Repository. I added so many new features and all my Pull requests were Merged.

This is where the Sad Story Starts :( After ten days when I opened my Forked Repo on GitHub Website this is what I saw:

This branch is 12 commits behind Hipo:master

After this I searched web for many hours but can't find solution for GitHub Desktop I know there are tons of tutorial for CMD but I need to know how to sync with original Repo from Desktop Application of GitHub ?

I am new so SORRY if i asked something stupidish :) Thanks

Oven answered 8/9, 2017 at 7:9 Comment(6)
Why don't you follow help.github.com/articles/syncing-a-fork and get it done. Github Desktop is a GUI that would not provided a button for each use case that you've - rather, it will work only for generic use cases.Stonechat
No matter what interface you use for Git (GUI or command line), the steps to update your fork are always the same. Therefore, check out the answers to existing questions. This one for example: #7244821Pellagra
Possible duplicate of How do I update a GitHub forked repository?Pellagra
@Pellagra I already mentioned in question that there are ton of tutorial for CMD but I wanted answer for Desktop.Oven
@Zakawat The steps are just the same: add original repository as a remote, fetch that and then merge or rebase. It doesn't matter through which interface you do this. Read the documentation for GitHub desktop or look for more specific questions to figure out how to perform the individual tasks. As a general remark: learn how to use Git on the CLI before using any UI. It will make things like this much easier to understand and sooner or later you have to use it anyway. Trust me. 😉Pellagra
@Pellagra After 1 Year and 6 Months I do realize your words: “learn how to use Git on the CLI before using any UI. It will make things like this much easier to understand and sooner or later you have to use it anyway” and here I am using CLI for almost everything !! Thanks !! 😇Oven
E
57

To sync the master of your fork to the master of the original repository using GitHub Desktop:

Click on the 'current branch' tab and first select 'master' as the current branch (if it's not already selected).

Click on the 'fetch origin' button.

Click on the 'current branch' tab again and click the 'choose a branch to merge into master' button at the bottom.

Button "choose a branch to merge into master"

*NOTE: Looking down this list, you will find 2 entries for every branch. Those that are prefixed with origin/ are the branches in your fork, and those prefixed with upstream/ are those in the original repository on GitHub.

Select upstream/master from this list, and this pull the changes down from the master repository to bring your local clone up to date.

Select upstream/master from this list

Once you local clone has finished pulling the updates from the master repo, push these new changes to your fork, stored on GitHub, using the push origin button on GitHub desktop.


2024 update: in more recent versions of GitHub Desktop, there are three options for merging in the popup screen from above:

  1. Merge commit
  2. Squash and merge
  3. Rebase

It's a little confusing, but the merge commit option will do a Fast Forward on your fork, unless your fork has diverged. This is what you typically want, as it will keep both histories equal.

If your fork has diverged, you may want to use Rebase. If your local fork is not meant to create PRs against the upstream branch. Squash and Merge in this scenario is probably not what you want here (your fork's history will not look the same anymore if you do that).

Entrain answered 29/11, 2018 at 11:28 Comment(4)
what if I don't find anything called upstream ? I'm seeing only the local branches.Poston
@SurjithSM I figured out why - if you are not logged into GitHub (e.g. only using SSH keys), upstream will not be there.Ply
Great answer, it´s tricky as the button Choose a branch to merge into master is hiding at the very bottom of the drop down menu, would never notice that :-)Winniewinnifred
does this sync the wiki as well?Kwasi
B
4

The popular answer didn't work for me - I kept getting a "A branch with that name already exists" error. Per this issue I found these instructions that did work:

  1. While in the default branch switch to the history tab
  2. Here you can select the branch called upstream/master and click "Merge into master"
Bibliotaph answered 26/8, 2020 at 2:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.