มีหลายวิธีที่จะทำเช่น:
ในกรณีที่คุณยังไม่ได้ส่งคำมั่นสัญญาต่อสาธารณะ:
git reset HEAD~1 --soft
เพียงเท่านี้การเปลี่ยนแปลงการส่งมอบของคุณจะอยู่ในไดเรกทอรีการทำงานของคุณในขณะที่การส่งมอบครั้งล่าสุดจะถูกลบออกจากสาขาปัจจุบันของคุณ ดูgit reset man
ในกรณีที่คุณทำแบบสาธารณะ (ในสาขาที่เรียกว่า 'ต้นแบบ'):
git checkout -b MyCommit //save your commit in a separate branch just in case (so you don't have to dig it from reflog in case you screw up :) )
ย้อนกลับกระทำตามปกติและผลักดัน
git checkout master
git revert a8172f36 #hash of the commit you want to destroy
# this introduces a new commit (say, it's hash is 86b48ba) which removes changes, introduced in the commit in question (but those changes are still visible in the history)
git push origin master
ตอนนี้ถ้าคุณต้องการให้มีการเปลี่ยนแปลงเหล่านั้นที่คุณเปลี่ยนแปลงในท้องถิ่นในการคัดลอกการทำงานของคุณ ( "เพื่อให้สำเนาท้องถิ่นของคุณช่วยให้การเปลี่ยนแปลงที่ทำในการที่กระทำ") - เพียงแค่ย้อนกลับย้อนกลับกระทำกับ--no-commitตัวเลือก:
git revert --no-commit 86b48ba (hash of the revert commit).
ฉันทำตัวอย่างเล็ก ๆ น้อย ๆ : https://github.com/Isantipov/git-revert/commits/master