---
title: "以前のコミットをリポジトリに強制プッシュする"
description: "コードをプッシュした後で、以前のコミットを強制プッシュしたい場合は次のように実行できます shell git push origin +commit\\sha^:branch\\name"
canonical: https://oozou.com/til/force-push-previous-commit-to-repo-44
locale: ja
date: 2020-10-13
topic: shell
---

# 以前のコミットをリポジトリに強制プッシュする

> コードをプッシュした後で、以前のコミットを強制プッシュしたい場合は次のように実行できます shell git push origin +commit\sha^:branch\name

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

コードをプッシュした後で、以前のコミットを強制プッシュしたい場合は次のように実行できます
*shell
git push origin +commit\_sha^:branch\_name*

Git は *sha^* を *sha* の親として、*+* を強制的な non-fastforward プッシュとして解釈します。

*HEAD^* を使うこともできます。*^* は *HEAD* の親を表すので、*HEAD^^^* とすると現在のコミットの 3 つ前のコミットがプッシュされます。
例：
*shell
git push origin +HEAD^^^:feature/i\_did\_an\_oopsie*

---

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

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