23

How to delete a file and folder from github.com repository using github.com's web interface? I searched on Google, but haven't found any answer.

I have found about how to do using commands

However I want to know how to do it using github.com.

migrated from webmasters.stackexchange.com Aug 29 '12 at 11:43

This question came from our site for pro webmasters.

  • There's definitely a way to edit files, but I'm not sure there's a way to delete them. Anyway, you might want the commands regardless. Learning git in the terminal or via a GUI will pay dividends. – Christopher Aug 29 '12 at 13:00
  • This is a valid question, even for experienced Git users. I use git from the command line, but I just forked a repo, made a quick change, and now I'd like to remove a file that's no longer needed, without having to clone the repo on my own machine. – Brian Mortenson Jan 31 '13 at 22:35
  • I added a solution that although not directly from GitHub (it's with prose.io), will deletes all the files and as an outcome will also remove the folder since it's empty. It's done with a script, so no need to manually remove multiple files. – arieljannai Jun 12 '18 at 21:15
12

You can delete a file using delete button but you cannot directly delete a folder via the web-interface. The way to delete a folder from GitHub.com is to delete every file inside it.

  • That's exactly what I said in my answer. – amar Dec 8 '15 at 23:01
3

I've found that deleting all files in a folder will automatically delete the folder. Not a perfect solution, but it seems intended.

2

You didn't specify your exact circumstances so this answer may not be what you want, but if you are using Windows you can install Github for Windows, which allows you to do all the regular Git operations without the command line.

You would need to first check out the repo to a folder, delete the file from the folder (i.e. in Windows Explorer), then commit your changes and sync back to the Github repo.

  • 3
    I’s say that using github.com's web interface is very exact. Your answer is correct, but it has nothing to do with the question. – Alex Aug 29 '12 at 15:46
  • That's fine, but the OP didn't really state what his problem was, only that he doesn't like the command line. In the same way that "how to parse HTML with regex" questions on SO are answered with "solve your problem a different way" my answer is an alternative method, on the off-chance it solves whatever problem he has. Clearly you are welcome to offer a better answer if there is one. – DisgruntledGoat Aug 29 '12 at 15:59
  • Actually, he did: “How to delete a file and folder from github.com repository using github.com's web interface?” He wants to delete a file using the web interface—the web site/web app/github.com. – Alex Aug 29 '12 at 16:31
  • No, he didn't. The title here is a question, not a problem. Plenty of people ask a question they think will solve their problem, but there is a better way to solve the problem. That may or may not be the case here, we'll have to wait for the OP to reply. – DisgruntledGoat Aug 30 '12 at 1:32
2

This functionality has now been added to the GitHub web interface.

enter image description here

  • 2
    Do you have any reference for this, like a blog post or screenshot of the desired functionality? – Andrew Lott Aug 2 '13 at 16:48
  • Sure, see the screenshot and after a bit of searching I found the blog entry too :-) – Dogsbody Aug 3 '13 at 23:54
2

Deleting folders from the Github web interface is not possible: https://github.com/isaacs/github/issues/225

It is on the feature list and will remain there for a while I guess.

2

You have few options:

  1. Delete all the files from that folder and github will delete the folder automatically.
  2. Clone the repository in your local machine and delete the folder (for this you can use either git bash/cmd depending upon your system or github desktop application if installed in your system) and sync it back to the server.
0

I have found an partial solution. We can delete file from github using http://prose.io but only files not folders

  • prose.io is the right answer as to how to delete a file from github through a web interface - it's not github's interface - but it totally works awesome. I was just looking for how to do this without going to the cryptic command line and it is perfect for the job :-D – user1778402 Apr 4 '13 at 21:58
0

I know it's not from GitHub's interface, but I hope this solution will fit. It does not require anything else than your browser and it solves the problem better than with just GitHub's interface.

The scripty way

Preperations

  1. Connect your GitHub account to prose.io to manage your projects.
  2. Open the desired folder you wish to delete.
  3. Use this script [1]

What it does?

It iterates over the files in the current folder an deletes them. When there aren't any files in a certain folder - GitHub removes it.

var deleteSuccessful = 0, deleteFailed = 0;
var elements = $('a.delete');
var totalElements = elements.length;

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

async function deleteFiles() {
    for (var i = 0; i < totalElements; i++) {
        var element = elements[i];
        var realConfirm = window.confirm;
        window.confirm = function(){
            window.confirm = realConfirm;
            return true;
        };
        try {
            element.click();
            deleteSuccessful += 1;
        } catch (error) {
            deleteFailed += 1;
        }

        await sleep(1000);
    }

    console.log("Total items identified: %d\nDeleted: %d\nFailed: %d\n** Operation %s **", 
        totalElements, deleteSuccessful, deleteFailed, totalElements == deleteSuccessful ? "successful" : "failed");
}

deleteFiles();

[1] You can either enter it in the browser console and run it, or minimize it and use it as a bookmarklet


Tested on Chrome 67.


Sources used: 1, 2

Not the answer you're looking for? Browse other questions tagged or ask your own question.