home / tils / til

Menu
  • GraphQL API

til: git_remove-commit-and-force-push.md

Export data

til

This row where path = "git_remove-commit-and-force-push.md"

TSV
Tab-separated values, for pasting into Excel or Google Sheets
CSV
Comma-separated values, for spreadsheets and other tools
  • JSON
    The row inside an object, with extra details
    View Download

path
git_remove-commit-and-force-push.md
topic
git
title
Removing a git commit and force pushing to remove it from history
url
https://github.com/simonw/til/blob/main/git/remove-commit-and-force-push.md
body
I accidentally triggered a commit which added a big chunk of unwanted data to my repository. I didn't want this to stick around in the history forever, and no-one else was pulling from the repo, so I decided to use force push to remove the rogue commit entirely. I figured out the commit hash of the previous version that I wanted to restore and ran: git reset --hard 1909f93 Then I ran the force push like this: git push --force origin main See https://github.com/simonw/sf-tree-history/issues/1
html
<p>I accidentally triggered a commit which added a big chunk of unwanted data to my repository. I didn't want this to stick around in the history forever, and no-one else was pulling from the repo, so I decided to use force push to remove the rogue commit entirely.</p> <p>I figured out the commit hash of the previous version that I wanted to restore and ran:</p> <pre><code>git reset --hard 1909f93 </code></pre> <p>Then I ran the force push like this:</p> <pre><code>git push --force origin main </code></pre> <p>See <a href="https://github.com/simonw/sf-tree-history/issues/1">https://github.com/simonw/sf-tree-history/issues/1</a></p>
shot
<Binary: 58,327 bytes>
created
2021-10-22T12:25:57-07:00
created_utc
2021-10-22T19:25:57+00:00
updated
2021-10-22T12:25:57-07:00
updated_utc
2021-10-22T19:25:57+00:00
shot_hash
0885470afde1e0e022cfd0757da982a4
slug
remove-commit-and-force-push
Powered by Datasette · How this site works · Code of conduct