---
title: "Force push previous commit to repo"
description: "If you push some code and want to force push a previous commit you can do so with shell git push origin +commit\\sha^:branch\\name"
canonical: https://oozou.com/til/force-push-previous-commit-to-repo-44
locale: en
date: 2020-10-13
topic: shell
---

# Force push previous commit to repo

> If you push some code and want to force push a previous commit you can do so with shell git push origin +commit\sha^:branch\name

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

If you push some code and want to force push a previous commit you can do so with
*shell
git push origin +commit\_sha^:branch\_name*

Where git interprets *sha^* as the parent of *sha* and *+* as a forced non-fastforward push.

You can also use *HEAD^* where *^* is the parent of *HEAD* so *HEAD^^^* would push the commit 3 commits before the current commit.
e.g.
*shell
git push origin +HEAD^^^:feature/i\_did\_an\_oopsie*

---

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

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