Pergunta

I am having trouble forcing my fork of a GitHub repo to be a complete copy of the original (master) repo. My fork has diverged and I want to bring it back to the same state as the original. However, the stack overflow posts I found that address the subject aren't working for me. For example, these two:

Completely replace Fork with origin (github)

Updating forked GitHub repo to match original's latest code and commits

I already had set "upstream" to point to the original repo's master branch. However, fetching updates and then merging, or using either of the rebase command variations found in the two SO posts above don't work for me. I still see the latest versions of my repo's files. Instead, I want to see the versions of the files in the state they exist in the master repo's master branch. I don't.

What might I be doing wrong? Is it it because I tried the rebase option after I used the "git fetch upstream" command followed by the "git merge upstream/master" command, and then pushed some changes to my fork's master branch? Note, I don't care about any new changes I've made since the master repo's master branch has all my previous important changes. All I need is a straightforward series of GitHub commands to force my fork to match the original repo's master branch.

From the following SO post:

How to force GitHub Fork (origin) to take Repository (upstream) version

I tried:

git reset --hard cb2a1828f0cbd02179849035c0adae8a7426b3f0

Where cb2a1828f0cbd02179849035c0adae8a7426b3f0 is the latest commit ID in the master repo's master branch. But I got the following error:

fatal: Could not parse object 'cb2a1828f0cbd02179849035c0adae8a7426b3f0'.

BTW, I know that I should have been working with a branch off of my master and then used my master branch only to fetch updates from the master repo's master. I will be doing that in the future. For now, I just need to get beyond this problem.

Foi útil?

Solução

The simplest way would be to:

  • delete your fork on GitHub
  • re-fork it
  • clone it locally

If you have some work in progress from your former local clone, you can:

  • add your first local clone as a remote of your new local clone
  • fetch / merge some of the commits to your current local clone
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top