2

ライブ展開のためにプッシュするベア git リポジトリを備えたサーバーがあります。post-receiveサーバーコードを最新の on で更新する単純なフックがありますmaster

実稼働サーバーでバグが見つかった場合、特定の過去のコミットに戻す必要がある場合があります (ローカルで自分自身をテストしますが、すべてをキャッチするわけではありません)。このセットアップで過去のコミットに戻す良い*方法はありますか?

*ナイスとは、裸のリポジトリにプッシュするようなワンライナーを意味します:git push prod master

4

1 に答える 1

5

If you want to keep your mistake in the history, this will add commits which compensate the commits you specify. (master must be checked out locally) For example, if you want to revert the last commit, you can use:

git revert master
git push origin master

If you want to remove the last 2 commits from history (master must be checked out locally):

git reset master~2
git push -f origin master

Or without changing anything local, this should work as well:

git push -f origin master~2:master

The last two will force-update the master to the third from last master commit. Which is problematic if someone else already pulled the commits you are removing.

于 2013-07-01T21:57:55.897 に答える