How to sync forked repo with commits in the Pull Request on github?

Viewed 216

I have forked a github repository, created another branch and after making my changes opened a Pull Request.

Then author of repo made his own changes and committed.

Normally, I thought that his commit/changes will get in sync with mine unfortunately that doesn't seem to be the case when I checked locally.

How to get his commits to my forked repo?

EDIT:

after trying to fetch and rebase from upstream, I getting the following error:

fatal: Needed a single revision
invalid upstream 'upstream/mybranchname'

The Pull Request on Github has fewer commits, author apparently squashed them.

The Pull Request is still open and it hasn't been merged yet.

1 Answers

Checkout your branch, then do:

git fetch upstream
git rebase upstream/master
git push -f

Then do the pull request again.

In the unlikely event that the remote for the repo owner is not called upstream or the branch you want to merge into is not called master, you will need to change those.

If you don't have an upstream remote, you need to add it with:

git remote add upstream https://github.com/somename/somerepo.git

where the last parameter points to the repo owner's repo.

Also there may be conflicts on the rebase. Either resolve them or do:

git rebase --abort
Related