-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing a git commit and force pushing to remove it from history
- Loading branch information
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Removing a git commit and force pushing to remove it from history | ||
|
||
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 |