I\'ve completely messed up the master branch of my forked git repo.
I want to completely reset the master branch that was pushed to my fork with the contents of the
I have tried the method like this:
$REPO=
$ORIGIN=/$REPO
$UPSTREAM=/$REPO
$ git clone git@github.com:$ORIGIN.git
$ cd $REPO
$ git checkout master
$ git remote add upstream git@github.com:$UPSTREAM.git
$ git reset --hard upstream/master
$ git pull --rebase upstream master
$ git push origin master --force
the output will show a warning:
fatal: ambiguous argument 'upstream/master':
unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
So the correct way is put git pull before git reset:
$ git clone git@github.com:$ORIGIN.git
$ cd $REPO
$ git checkout master
$ git remote add upstream git@github.com:$UPSTREAM.git
$ git pull --rebase upstream master
$ git reset --hard upstream/master
$ git push origin master --force
then the output will be like this:
From github.com:/
* branch master -> FETCH_HEAD
* [new branch] master -> upstream/master
HEAD is now at 7a94b1790 Merge pull request #4237 from /...
Current branch master is up to date.
Everything up-to-date.