简体   繁体   中英

Is there a way to delete a folder from a github repository through the website?

I don't really know how to add,remove, or update my github repositories through terminal and I accidentally saved a second copy of a folder inside a folder a few saves back. Is there any way through the site to remove the entire folder rather than the files inside on the actual website?

Git does not store folders at all. If you have files a/one , a/two , and a/three , that's not a folder named a with three files in it, that's three files whose names are a/one , a/two , and so on.

That said, the GitHub website does have the ability to make a new commit with one file added, changed, or deleted. For the process for deleting one file, see https://help.github.com/en/github/managing-files-in-a-repository/deleting-files .

Note that you will make one new commit each time: you'll start from some existing commit, which has (say) the three files a/one , a/two , a/three , and various other files as well. You pick one, delete it, and make a new commit: this new commit now has two files whose name starts with a/ , plus the remaining files as well.

Now you may pick the second of the three files. Using the interface, delete it and commit: the new commit has only one a/ file, plus all the others. Pick the last one and delete it and commit: this commit has no a/ files; it has only the others. This third commit has the state you wanted.

This is, of course, totally the wrong way to handle this. Just get a command-line Git, clone the repository, remove all three files, commit once, and use git push to send the (single) commit that has all the other files, but has these three removed. Or, if there are more (or fewer) than three such files, you still make one commit that has all the other files, but no longer has these files.

Remember that all the existing commits remain untouched. The new commit is simply a commit that still has all the other files, but lacks any files whose name will, on your computer, require creating some specific folder—so when you clone the repository and use that commit, Git won't create that folder. It won't need to; the files that would need that folder, aren't in that commit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM