---
title: "Force push commit ก่อนหน้าขึ้น repo"
description: "ถ้า push โค้ดไปแล้วและอยากจะ force push commit ก่อนหน้า ทำได้ด้วย shell git push origin +commit\\sha^:branch\\name"
canonical: https://oozou.com/til/force-push-previous-commit-to-repo-44
locale: th
date: 2020-10-13
topic: shell
---

# Force push commit ก่อนหน้าขึ้น repo

> ถ้า push โค้ดไปแล้วและอยากจะ force push commit ก่อนหน้า ทำได้ด้วย shell git push origin +commit\sha^:branch\name

Published: 2020-10-13 · Topic: [shell](https://oozou.com/th/til-topics/shell) ([markdown](https://oozou.com/th/til-topics/shell.md))

ถ้า push โค้ดไปแล้วและอยากจะ force push commit ก่อนหน้า ทำได้ด้วย
*shell
git push origin +commit\_sha^:branch\_name*

โดย git จะตีความ *sha^* ว่าเป็น parent ของ *sha* และ *+* คือการ force push แบบ non-fastforward

นอกจากนี้ยังใช้ *HEAD^* ได้ด้วย โดย *^* คือ parent ของ *HEAD* ดังนั้น *HEAD^^^* จะ push commit ที่อยู่ก่อน commit ปัจจุบัน 3 commit
เช่น
*shell
git push origin +HEAD^^^:feature/i\_did\_an\_oopsie*

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/th/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
