Is there a way to entirely remove a directory and its history from GitHub?
4 Answers
If you are asking about deleting a project from GitHub, open your project, click the "Admin" tab (or browse directly to https://github.com/username/project_name/edit) and on the bottom of the page, click "Delete This Repository". It'll ask you to confirm this, and then it's gone.
If you just want to erase a part of your repository, you need to do it to your git repository and push it to GitHub.
GitHub has written a howto about this in their FAQ. I Haven't tried this myself, so I can't guide you further, but you probably can manage this yourself here on.
In either case, this, naturally, doesn't delete any third party pulls – if someone has pulled the repository before you deleted it, it's out, without you being able to do much about it (other than trying the "pretty please"-technique).

- 14,195
- 22
- 56
- 52

- 66,919
- 31
- 85
- 96
-
4I don't know where I heard that first, but there is a nice saying in the Git community: "Git works just like the real world: if you want to rewrite history, you need a conspiracy". IOW, if you want to remove a directory from the history, everybody who ever cloned that repository has to be "in on it" – Jörg W Mittag Jan 14 '09 at 18:11
-
Yeah, that, or they mistakenly pull from the central git repo. I guess that way their local histories would be erased too, although I'm not sure... – Henrik Paul Jan 14 '09 at 19:56
-
No, they won't. Old history only gets deleted when it is no longer referenced by anything *and* you run the garbage collector. Which means that by default it won't get deleted for at least 2 weeks, because that's how long they will stay in the reflog. As long as they are in the reflog, you just ... – Jörg W Mittag Jan 14 '09 at 21:05
-
... do `git checkout HEAD@{10.minutes.ago}` and you're back in business. In distributed version control, you have *no control* over what anybody else does with their repositories. That's the *point* of DVCS. (No *technical* control. You could have *social* controls, like work contracts.) – Jörg W Mittag Jan 14 '09 at 21:08
To selectively delete a file or directory (and all its associated history), you can use git filter-branch
.
This is very useful when you want to completely delete files checked into the repository by mistake.
The syntax is simple:
git filter-branch --tree-filter 'rm -f filename' HEAD
More info on the man page.

- 866
- 1
- 8
- 22

- 19,928
- 10
- 56
- 60
-
2Doesn't really answer the question asked by the author, however it is definitely useful. – Nick Stinemates Oct 05 '09 at 23:13
This is the easiest way the deletes a directory from your GitHub repo but not local system:
git rm -r --cached FolderName
git commit -m "Removed folder from repository"
git push origin master

- 2,501
- 2
- 17
- 25
Go to the edit tab; there’s a delete link at the bottom of the page.

- 21,119
- 15
- 74
- 98
-
Not as in-depth as the expected answer. Did not mention name of label, what side of the page, etc. – Nick Stinemates Oct 05 '09 at 22:55