何が起こったのか: change1、git commit、git push、change2、git commit
何が起こるべきか: change1, git commit, git push, change2, git commit --amend
change2 を保持することは重要ではありませんが、元のコミットを修正できることは重要です。どうすればいいですか?
プッシュしたので、これはトリッキーであり、履歴を書き換えていることに注意してください。
最初のコミットの前に、提示されたテキストでコミットgit rebase -i
を選択できます。edit
このようにして、変更/修正する最初のコミット状態になり、git が次のコミットを適用します。
またはgit reset --soft first
、最初のコミットに移動して、change2 と共に修正することもできます。
またはgit reset --hard first
、最初のコミットに移動して、変更なしで修正する2
[ライナスはこれが悪だと思っていることを知っていると思います]
$ git reset --hard HEAD^ # remove last commit
$ git commit --amend
$ git push --force <remote> <branch>
最後のコミットを後で適用したい場合は、
$ SHA1=`git rev-parse master`
$ git branch temp
# now the three commands above
$ git cherry-pick $SHA1
$ git branch -d temp