Skip to main content

Deleting files in a repository

You can delete an individual file or an entire directory in your repository on GitHub Enterprise Server.

People with write permissions can delete files or directories in a repository.

About file and directory deletion

You can delete an individual file in your repository or an entire directory, including all the files in the directory.

If you try to delete a file or directory in a repository that you don’t have write permissions to, we'll fork the project to your personal account and help you send a pull request to the original repository after you commit your change. For more information, see "About pull requests."

If the file or directory you deleted contains sensitive data, the data will still be available in the repository's Git history. To completely remove the file from GitHub Enterprise Server, you must remove the file from your repository's history. For more information, see "Removing sensitive data from a repository."

Deleting a file

  1. Browse to the file in your repository that you want to delete.

  2. At the top of the file, click .

  3. 在页面底部,输入一条简短、有意义的提交消息,描述您对文件所作的更改。 您可以在提交消息中将提交归于多个作者。 更多信息请参阅“创建有多个合作作者的提交”。 有关更改的提交消息

  4. 在提交消息字段下面,确定是要将提交添加到当前分支还是新分支。 如果当前分支是默认分支,则应选择为提交创建新分支,然后创建拉取请求。 更多信息请参阅“创建新的拉取请求”。 提交分支选项

  5. 单击 Propose file change(提议文件更改)提议文件更改按钮

Deleting a directory

  1. Browse to the directory in your repository that you want to delete.

  2. In the top-right corner, click , then click Delete directory. Button to delete a directory

  3. Review the files you will delete.

  4. 在页面底部,输入一条简短、有意义的提交消息,描述您对文件所作的更改。 您可以在提交消息中将提交归于多个作者。 更多信息请参阅“创建有多个合作作者的提交”。 有关更改的提交消息

  5. 在提交消息字段下面,确定是要将提交添加到当前分支还是新分支。 如果当前分支是默认分支,则应选择为提交创建新分支,然后创建拉取请求。 更多信息请参阅“创建新的拉取请求”。 提交分支选项

  6. 单击 Propose file change(提议文件更改)提议文件更改按钮