0

I have spend half an hour reading questions and answers and still I didn't find a simple way to do this. So, is there an easy way to remove unwanted file from Github history (just to name the file and delete it)?

Damjan Pavlica
  • 31,277
  • 10
  • 71
  • 76
  • 1
    I haven't down-voted, but I would guess the downvotes are because this question could be construed as a duplicate: http://stackoverflow.com/a/21031833/438886 http://stackoverflow.com/a/14656358/438886 http://stackoverflow.com/a/17890278/438886 - removing files from history is a confusing area even for experienced Git users, and people ask about it in lots of different ways. I was even asked by a Stackoverflow moderator to stop answering them, because so many of my answers mentioned my own project, the BFG :| Let me know if you found my answer helpful! – Roberto Tyley Jan 04 '15 at 09:48
  • Thanks a lot man, I am a git beginner and I realy just wanted to know is it possible to do this without too much procedure. – Damjan Pavlica Jan 04 '15 at 10:03

2 Answers2

3

As @VonC says, GitHub doesn't provide the ability to remove files from history through their UI. As an outsider, this would be my view on why that's so:

  • Once the data is up on GitHub, it's already too late in some sense. If the data is private then putting it on GitHub has already compromised that privacy. If the data is just really big, GitHub already has filters in place to stop any file bigger than 100MB being pushed up.
  • Rewriting history (especially to remove data) is obviously very destructive & disruptive - the kind of thing you don't necessarily want to make easy. If they did include it, they'd have to surround it with ugly confirmation are-you-really-sure dialogs.
  • Until I created the BFG, the main tool for removing files from git history was git filter-branch, which is very slow on big repos - GitHub would have had to chuck these clean-up jobs on to a long-running queue, and tell you to come back later. In the case of a big repo, it could have taken days to complete the job.

Given all that, it's quite reasonable that GitHub don't support it themselves. You are expected to do it yourself from the command-line- but it's not that hard, I wrote the BFG to make this process simple:

bfg --delete-files myBad.mp3

...the BFG is now recommended by GitHub, Atlassian, and also in the docs for git filter-branch itself.

Incidentally, Git is the underlying source-control software, GitHub is a company that provides hosted-Git (so you're rewriting Git history, rather than GitHub history really).

Full disclosure: I'm the author of the BFG Repo-Cleaner.

Roberto Tyley
  • 24,513
  • 11
  • 72
  • 101
1

Not from GitHub directly.

You would still have to clone it locally, clean it (with BFG for instance, faster than the git filter-branch), and push it back.
The push would be a force one git push --force, which means you need to notify other users of that repo, for them to reset their own clone.

For instance (with bfg: "Cleaning Up Git Repositories With The BFG Repo-Cleaner"):

bfg --delete-files id_{dsa,rsa}  my-repo.git
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250