Removing code from GitHub

前端 未结 4 1214
抹茶落季
抹茶落季 2020-12-25 11:23

Is there a way to entirely remove a directory and its history from GitHub?

相关标签:
4条回答
  • 2020-12-25 11:43

    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).

    0 讨论(0)
  • 2020-12-25 11:45

    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
    
    0 讨论(0)
  • 2020-12-25 12:01

    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.

    0 讨论(0)
  • 2020-12-25 12:05

    Go to the edit tab; there’s a delete link at the bottom of the page.

    0 讨论(0)
提交回复
热议问题