We need to go back in time to a particular commit. Some accidental changes were made to master. Attempts to revert it dug too deep, so master is in a bad state. We now want master to go back to 66ada4cc61d62afc.
According to git revert back to certain commit:
$ git reset --hard 66ada4cc61d62afc
HEAD is now at 66ada4c Updated documentation
Then, trying to commit it:
$ git add *.h *.cpp
$ git commit -m "Go back to Commit 66ada4cc61d62afc"
On branch master
Your branch is behind 'origin/master' by 16 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working directory clean
And finally:
$ git push
To https://github.com/weidai11/cryptopp.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/weidai11/cryptopp.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Right now, everything is exactly where I want it to be. I have no idea why Git is having trouble, and what Git is talking about. It sure would be nice if Git did what it was told. But alas, Git makes every simple task difficult, and its going to inflict undue pain and suffering.
How do I commit and push the changes?
To avoid partial solutions that simply exchanged one set of errors for another, I performed the following:
git clone https://github.com/weidai11/cryptopp.git cryptopp-old
git clone https://github.com/weidai11/cryptopp.git cryptopp-new
cd cryptopp-old
git checkout 66ada4cc61d62afc
cd ../cryptopp-new
cp ../cryptopp-old/*.h ../cryptopp-old/*.cpp .
git commit -am "Go back to Commit 66ada4cc61d62afc"