5 ms·
Github is amazing. But I don't like how it's exceptionally hard to delete history of commits. I've looked around for a long time to delete commits safely and pe
by Datsundere 14y ago
Github is amazing. But I don't like how it's exceptionally hard to delete history of commits. I've looked around for a long time to delete commits safely and people say things like "you shouldn't be doing it anyway."
A free software should provide freedom to the user to do anything they wish. I fee like I'm chained down when I want to delete very old commits.
I'm sure there are ways to delete commits, but it is just so complicated.
- tibbon 14y agoIt would be nice if there was a "delete all references to this file" button on Github. If suddenly a file is up there that was never supposed to be, a single click to purge it from all existence would be great.
- plorkyeran 14y agoDeleting commits in git is trivial compared to every other VCS I've used. Deleting the most recent commit is just 'git reset HEAD~1 --hard' and deleting an older commit is just 'git rebase -i commit-to-delete~1' and then remove the line for the appropriate commit. After deleting the commit locally, you then just have to push with -f to Github.
- sergiosgc 14y agoResetting the head to a previous commit will not delete the commit. It will be left dangling in the git the commit graph (it is not a head and has no children). Rebasing does delete the commit but can be done only on local commits (commits not yet pushed anywhere else). Never mess with the history of replicated repos!
- klodolph 14y ago"Never" is too strong here. There are plenty of legitimate reasons for messing with replicated history. For example, what if you have copyright violations (lifted code), personal details (SSNs), or child pornography in the repository's commit history. The advice is: "Messing with the history of replicated repos is a major undertaking and is not to be undertaken lightly." But I guess that doesn't roll of the tongue as well as "never".
- pyre 14y ago| A free software should provide freedom to the user | to do anything they wish. There is freedom. It's the same freedom that allows the root user to `dd` over the master boot record on a Linux install. People tell you to shy away from it because you can shoot yourself in the foot, not because it's not possible. Look into git-filter-branch for wholesale rewriting of commits.
- nathan_long 14y agoGithub has nothing to do with that. It's hard to delete commits from git, because of the way it fundamentally works. Part of what defines a commit is its parent commit (or commits, plural, if it's a merge), and that chain goes back to the beginning of the repo. This means that you can't remove a commit from the history without changing everything that came after. Well, you can do that, but suddenly no one else who works with your repo will be able to pull changes, because there is no way to reconcile the histories. Think of them as divergent timelines. They're like, "last thing I saw, Obama got re-elected; what's happened since then?", and your modified repo is like, "Uh, I don't know who this 'Obama' fellow is, and don't let the Lizard King hear you talking about elections."
- rickyc091 14y agoGithub recently published this after the whole search debacle. You can use it to prune all existence of a file form your history. https://help.github.com/articles/remove-sensitive-data https://help.github.com/articles/remove-sensitive-data
- joshfraser 14y ago"Fortunately, git makes it fairly simple to remove the file from the entire repo history." Sounds like they have a unique definition of "simple".
- insteadof 14y agoThey recently linked to it. But the article itself has been around for as long as they've had help articles on how to use Git and GitHub.