I have forked a repository, then I made some changes and it looks like I’ve messed up everything.
I wish to start it again from scratch, using the current upstream/master as the base for my work.
Should I rebase my repository or delete it at all?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The simplest solution would be (using ‘
upstream‘ as the remote name referencing the original repo forked):(Similar to this GitHub page, section “What should I do if I’m in a bad situation?”)
Be aware that you can lose changes done on the
masterbranch (both locally, because of thereset --hard, and on the remote side, because of thepush --force).An alternative would be, if you want to preserve your commits on
master, to replay those commits on top of the currentupstream/master.Replace the reset part by a
git rebase upstream/master. You will then still need to force push.See also “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.Note: recent GitHub repos do protect the
masterbranch againstpush --force.So you will have to un-protect
masterfirst (see picture below), and then re-protect it after force-pushing).Note: on GitHub specifically, there is now (February 2019) a shortcut to delete forked repos for pull requests that have been merged upstream.