1

I have forked a repo (Original) into my github account. The Original repo changed and also I have some comits behind the Original repo. I did a merge from Original into my workspace but I still see my intermediary commits.

I need to have a clean forked repo (identical as the Origial). How can I do that from the web interface.?

Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154
georgiana_e
  • 1,809
  • 10
  • 35
  • 54
  • I'm afraid GitHub doesn't support this kind of activity. Though, when you do merge, you may choose to have fast forward merges without merge commit. This is probably what you may use to workaround the problem. – 0andriy Mar 10 '20 at 09:15
  • Does this answer your question? [Clean up a fork and restart it from the upstream](https://stackoverflow.com/questions/9646167/clean-up-a-fork-and-restart-it-from-the-upstream) – Joe Mar 10 '20 at 12:02

1 Answers1

0

At this point in time, there's no way to do a git-reset through the GitHub Web UI.

However, it's fairly easy to do on the command-line:

# 1. Add the Original repo as a remote to your local repository
git remote add upstream https://github.com/original/repo

# 2. Fetch all the objects from the Original repo
git fetch upstream

# 3. Reset your local `master` to point to the same commit as `master` on Original
git switch master
git reset --hard upstream/master

This is assuming that the branch you want to be identical to Original is master. If not, simply substitute master with the actual branch name.

Also, keep in mind that this will remove your own commits from the branch you're resetting. If you want to keep those around for later, simply create a branch that points to the latest of your own commits before you do the reset operation.

# Optional: Create a branch that points to your own commits before resetting `master`
git switch master
git branch my-own-commits
Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154