I forked a repository (which has one master
branch) in my local namespace.
Ever since, I have several commits on top of master
, and I also have an additional branch (test-branch
).
What I want to perform is:
master
branch to the state it was when I forked the repotest-branch
as isA potential way of going about this is to checkout master
, view the log history, find the sha
of the last commit that was not mine and perform a git reset <sha_of_last_commit_of_forked_repo>
.
Is there an alternative way?
fyi I have configured two remotes
: origin
and upstream
(the upstream is the repo I forked from, with push
).
You can do hard reset your local with upstream's master.
$ git checkout master
$ git fetch upstream # update local upstream history but not merged with working tree
$ git reset --hard upstream/master # replace local 'master' history = upstream/master history
Now, you can create and checkout to a new branch test-branch
from master
.
$ git checkout -b test-branch