git リモートブランチを前のバージョンに戻す

gitを使っていて、リモートブランチのログを戻したいなとおもって、
ググってみたがやりたい事と一致する記事がなかったのでメモ。

まず下記でローカルのバージョンを戻す。

$git reset --hard fdsa2432fda4f189a85a3319f9c782c0a49f8

※fdsa2432fda4f189a85a3319f9c782c0a49f8は git log等でどこに戻るか決める。
※–hardをつけないとローカルのソースは戻らないので編集中となるgit status 等で確認
※もしまちがったログに戻ってしまったりしたら git reflog で指定のHEADに戻る!

その後、pushしてリモートブランチのログを戻す!

$git push origin master

するとこんなエラーが、、、、

To https://user@examplegitgittesttest.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘https://user@examplegitgittesttest.git’
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. ‘git pull’)
hint: before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.

ですが、恐らくpushしようとしているバージョンが、
古いからエラーを出してくれているようなので(勝手な推測ですw)、
そんな時は、リモートブランチ名に「+」を追加!

$git push origin +master

※強制的にpush!!

これで、リモート上のログを見ると、指定のバージョンに戻ってました!