push取り消せた!取り消せたよ!
この前何かの手違いでマージしちゃった件が解決しました。
まずはgit logでハッシュを確認します*1。
$git log #(中略) commit 083b Author: yuxxxx Date: Sat Jul 28 03:12:53 2012 +0900 #ここでブランチ切った commit 0fe9 #ここまで戻すつもり Author: yuxxxx Date: Fri Jul 27 22:59:10 2012 +0900 commit b192 Author: yuxxxx Date: Fri Jul 27 22:58:21 2012 +0900 #(後略)
ハッシュをコピーしたらqを押して終了します。さらに続けてgit reset。
$ git reset 0fe9 Unstaged changes after reset: M index.html M index.js
これでローカル側は元に戻ったはずです。確認してみましょう。
$ git log commit 0fe9 Author: yuxxxx Date: Fri Jul 27 22:59:10 2012 +0900 commit b192 Author: yuxxxx Date: Fri Jul 27 22:58:21 2012 +0900 #(後略)
ちゃんとリビジョンが戻っていますね。ローカル側はこれでOKです。今度はリモート側を元に戻しましょう。ちなみにこのままいつもどおりpushしてもうまく行きませんでした。焦りますね。
$ git push Username for 'https://github.com': yuxxxx Password for 'https://yuxxxx@github.com': To https://github.com/yuxxxx/freezing-wight.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/yuxxxx/freezing-wight.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.
調べていると以下のようにするといいらしいとのことがわかったのでやってみます。
$ git rebase -i HEAD~2 #ここでエディタが開くのでダブったコミットログを削除して保存 Successfully rebased and updated refs/heads/master. $ git push origin +master Username for 'https://github.com': yuxxxx Password for 'https://yuxxxx@github.com': Total 0 (delta 0), reused 0 (delta 0) To https://github.com/yuxxxx/freezing-wight.git + eb83686...4b192c0 master -> master (forced update)
GitHubでも確認してみるとうまくいったようです。
参考にさせていただいたのはこちら。ありがとうございます。]
githubにpushしたcommitの取り消し - 七誌の開発日誌(旧)
http://d.hatena.ne.jp/n7shi/20100204/1265382280
*1:以下コメントログやハッシュの一部などを省略しています