maximus
maximus

Reputation: 4302

Reset fork to be the same as current original project (git)

I forked a project on github.com. Started to write code. committing and pushing it on my own forked version. However, then the original project's technology changed so that all folders deleted and created new ones. I did the same on my side, deleted folders and created new folders and files, but now I can't do pull requests because they are connected to the old version of the original project. How to update my fork so that it will be the same as curren't original project's version?

Upvotes: 2

Views: 204

Answers (2)

Guillaume Darmont
Guillaume Darmont

Reputation: 5018

If you don't need to keep the commits you made, the simplest way is to delete your local repository and do a fresh clone of the project.

If your commits were done on master and you want to keep them in a backup_branch, simply do :

  • git checkout -b backup_branch master

Then, to have your fork at the same point as the original project, do :

  • git fetch // Fetch new commits from remote repository
  • git branch -D master // Delete the master branch (it's just a branch like others)
  • git checkout -b master origin/master // Recreate master from remote origin/master

You can also repeat this operation for others branches than master if you need.

Upvotes: 3

sarahhodne
sarahhodne

Reputation: 10114

You probably either want to merge in the changes or start fresh. Merging the changes can be done like this:

git merge {remote}/{branch}

Where {remote} is the git remote that points to the upstream repository (probably origin if you git cloned the upstream repo), and {branch} is the branch you want to merge in changes from. If you have no idea what this is, it's fairly likely to be master.

Upvotes: 1

Related Questions