tampe125 tampe125 - 3 months ago 20
Git Question

Clean up a fork and restart it from the upstream

I have forked a repository, then I made some changes and it looks like I've messed up everything.

I'd wish to start it again from scratch, using the current upstream/master as base for my work.

Should I rebase my repository or delete it at all?


The simplest solution would be (using 'upstream' as the remote name referencing the original repo forked):

git remote add upstream /url/to/original/repo
git fetch upstream
git checkout master
git reset --hard upstream/master  
git push origin master --force 

(Similar to this GitHub page, section "What should I do if I’m in a bad situation?")

A more complete solution, backing up your current work (just in case) is detailed in "Cleanup git master branch and move some commit to new branch".

See also "Pull new updates from original Github repository into forked Github repository" for illustrating what "upstream" is.