# How to delete a file from a GitHub branch

**URL:** https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800
**Category:** General
**Created:** [September 5, 2025, 3:31pm UTC](https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800 "2025-09-05T15:31:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Nordic\_Dogsledding](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/nordic_dogsledding/32/547_2.png) [@Nordic\_Dogsledding](https://forum.ada-lang.io/u/Nordic_Dogsledding)
#### Post date: [September 5, 2025, 3:31pm UTC](https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800/1 "2025-09-05T15:31:16Z")

</div>

Docs say:

- Navigate to the repository and locate the file you want to delete.
- Click on the file to open it.
- Click the trash can icon (🗑) labeled “Delete this file” at the top right.

There is no trash icon. It’s my repository, I have write access, can edit files and upload - but not delete!

What the hell.

---

<div class="post-metadata">

### Author: ![RREE](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/rree/32/34_2.png) [@RREE](https://forum.ada-lang.io/u/RREE)
#### Post date: [September 5, 2025, 6:16pm UTC](https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800/2 "2025-09-05T18:16:11Z")

</div>

```ada
git switch my_branch
git rm file

```

---

<div class="post-metadata">

### Author: ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)
#### Post date: [September 5, 2025, 6:21pm UTC](https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800/3 "2025-09-05T18:21:41Z")

</div>

There is much to say here, but

1. Which docs are you talking about?
2. There is no trash can icon in the Github UI that I can remember of recent years
3. This is how you do it if doing it graphically (just a random repo of mine):

 ![Skjermbilde 2025-09-05 kl. 20.18.32](https://forum.ada-lang.io/uploads/default/original/1X/fbfac391f7bb0868ded86568e47e1e454ad137f3.png)

---

<div class="post-metadata">

### Author: ![fatso83](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/fatso83/32/624_2.png) [@fatso83](https://forum.ada-lang.io/u/fatso83)
#### Post date: [September 5, 2025, 6:23pm UTC](https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800/4 "2025-09-05T18:23:06Z")

</div>

The real answer is of course to spend 1 hour reading Chapter 1 through 3 of the free Pro Git book. Best spent hour of my professional career. [Pro Git by Scott Chacon](https://git-scm.com/book/en/v2)

---

<div class="post-metadata">

### Author: ![mgrojo](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/mgrojo/32/15_2.png) [@mgrojo](https://forum.ada-lang.io/u/mgrojo)
#### Post date: [September 5, 2025, 7:50pm UTC](https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800/5 "2025-09-05T19:50:58Z")

</div>

> [@fatso83](#):
>
> There is no trash can icon in the Github UI that I can remember of recent years

There was one.

 ![image](https://forum.ada-lang.io/uploads/default/original/1X/bb8f085b492d2d0ffa63e4c9b5d85f6b81a0f4ab.png)

The funny thing is that duckduckgo found that image on an article titled “How to Use GitHub in 2025”.

> **[What Is GitHub? Ultimate Guide on How to Use GitHub in 2025](https://hackr.io/blog/how-to-use-github)**
>
> Whether a coding newb or a seasoned pro, you need to know how to use GitHub. Check out our ultimate guide on how to use GitHub in 2025, including creating repos, pull requests, and more.

---

<div class="post-metadata">

### Author: ![Nordic\_Dogsledding](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/nordic_dogsledding/32/547_2.png) [@Nordic\_Dogsledding](https://forum.ada-lang.io/u/Nordic_Dogsledding)
#### Post date: [September 6, 2025, 6:15pm UTC](https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800/6 "2025-09-06T18:15:53Z")

</div>

> [@fatso83](#):
>
> Which docs are you talking about?

I asked the copilot and got irritating answers.

Thanks to you all for the links. Today I found the delete command - I would bet that it was not there the last time - mebby I’m blind…

---

<div class="post-metadata">

### Author: ![krischik](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/krischik/32/420_2.png) [@krischik](https://forum.ada-lang.io/u/krischik)
#### Post date: [September 7, 2025, 7:53am UTC](https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800/7 "2025-09-07T07:53:49Z")

</div>

> [@Nordic\_Dogsledding](#):
>
> I asked the copilot and got irritating answers.

Just for the fun of it I asked Grok:

* * *

I can definitely help with clear steps on how to delete a file from a GitHub branch! Here’s a straightforward guide:

### Steps to Delete a File from a GitHub Branch

#### Option 1: Using the GitHub Web Interface

1. **Navigate to the Repository** : Go to the GitHub repository in your browser.
2. **Switch to the Branch** : Use the branch dropdown menu to select the branch containing the file you want to delete.
3. **Locate the File** : Browse to the file you want to delete.
4. **Delete the File** :
  - Click on the file to open it.
  - Click the trash can icon (or “Delete this file”) at the top-right of the file view.

5. **Commit the Change** :
  - Enter a commit message describing the deletion (e.g., “Removed outdated file”).
  - Choose whether to commit directly to the branch or create a pull request.
  - Click “Commit changes” or “Propose file change” if creating a pull request.

6. **Verify Deletion** : Ensure the file is removed from the branch by checking the file list or pull request.

#### Option 2: Using Git Command Line

1. **Clone the Repository** (if not already cloned):

```bash
git clone <repository-url>
cd <repository-name>

```

2. **Switch to the Branch** :

```bash
git checkout <branch-name>

```

3. **Delete the File** :

```bash
git rm <file-path>

```

Example: `git rm docs/oldfile.txt`
4. **Commit the Change** :

```bash
git commit -m "Deleted <file-path>"

```

5. **Push to GitHub** :

```bash
git push origin <branch-name>

```

6. **Verify Deletion** : Check the branch on GitHub to confirm the file is gone.

#### Notes:

- If the file is in a pull request, deleting it via the web interface or CLI will update the pull request automatically.
- Ensure you have the necessary permissions to modify the branch.
- If the branch is protected, you may need to create a pull request and get approval to merge the deletion.

* * *

---

<div class="post-metadata">

### Author: ![RBSF](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/rbsf/32/1053_2.png) [@RBSF](https://forum.ada-lang.io/u/RBSF)
#### Post date: [August 13, 2026, 1:55pm UTC](https://forum.ada-lang.io/t/how-to-delete-a-file-from-a-github-branch/3800/8 "2026-08-13T13:55:04Z")

</div>

Looks interesting, will have a look. Thanks
