How can I remove it to make sure no one accidentally pulls that commit instead of the corrected version?
There's no need to do this, anybody using the master
branch on your repo will get the correct commit (i.e., whatever you happen to have master
branch pointing to at the time).
The reason that the other commit hasn't been garbage-collected is because there's still a reference to it somewhere.
In local repos this is usually the reflog, and the commit will be GC'd once it gets old enough that the reflog entry that indicates that HEAD
and/or master
pointed to that commit sometime in the past ages out and is GC'd, or is explicitly deleted.
GitHub is a bit more complex because there are plenty of things outside of a particular repo that can reference commits in a repo. This includes PRs, issues, and apparently even references in other repos, as the current message at the top of https://github.com/nylen/connectbot/commit/1cd775d indicates:
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I tried to track down where this reference might be by checking issues and PRs in the upstream repo and another fork repo mentioned in a PR for the "good" commit above. I didn't manage to track it down, but the upstream repo currently has 624 active forks, each with its own set of commits, PRs and issues (and whatever else GitHub has that references commits), so the reference is no doubt in there somewhere.
But again, there's no need to worry about this. Anybody looking at your master
branch will always get the "correct" commit as of the time they last fetched your repo on the tracking branch, and they'll have to resolve things in the usual way if they happen to have a local branch that they made reference the older version of that commit. (In situations like this one, usually a simple git rebase
will "replace" the old commit with the new one on the local branch.)