# Removing commits from a Pull Request

**URL:** <https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017>\
**Category:** freeCodeCamp Contributors\
**Tags:** contributing\
**Created:** [January 9, 2025, 3:19pm UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017 "2025-01-09T15:19:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephenmutheu](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/stephenmutheu/32/421476_2.png) [@stephenmutheu](https://forum.freecodecamp.org/u/stephenmutheu)\
**Post date:** [January 9, 2025, 3:19pm UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/1 "2025-01-09T15:19:44Z")

</div>

I have been on this issue for some time now. How can I remove commits from a PR? Another issue I am experiencing is that a new PR include older PRs. If I create a PR named X and then create another Y, Y will have two commits, X and Y instead of one.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 9, 2025, 3:55pm UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/2 "2025-01-09T15:55:45Z")

</div>

the commits on a PR are those on a branch.  
If you have extra commits on a branch it can mean:

- you created the branch from a branch that is not `main`
- your `main` is not clean

how to solve:  
make sure your `main` branch is up to date and doesn’t have extra commits with the upstream `main`.  
If your `main` has extra commits, while on `main` you should be able to reset it with `git reset --hard upstream/main`

After that, go to the branch for the PR and go `git rebase -i main`. This will allow you to do an interactive rebase, change the commits you need to remove to `d` or `drop`.  
After that you will need to `git push -f <branch-name>` to do a force push

---

<div class="post-metadata">

**Author:** ![stephenmutheu](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/stephenmutheu/32/421476_2.png) [@stephenmutheu](https://forum.freecodecamp.org/u/stephenmutheu)\
**Post date:** [January 10, 2025, 5:24am UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/3 "2025-01-10T05:24:43Z")

</div>

Hello.

Things have become tangled. It seems I am running into deeper problems with each command. The first command didn’t work, and after that, I was unable to switch between branches. The terminal is prompting that some of the filenames are too long. At this point, I am confused about what is what, I ran so many commands and think I might have conflicted myself.

Would it be a good idea to close the PR and open a new one?

---

<div class="post-metadata">

**Author:** ![sanity](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sanity/32/378897_2.png) [@sanity](https://forum.freecodecamp.org/u/sanity)\
**Post date:** [January 10, 2025, 6:06am UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/4 "2025-01-10T06:06:10Z")

</div>

As long as you are willing to tackle this, I’d keep trying to untangle this. Getting `main` branch in sync will be needed anyway to make further PRs without similar issues.

There are two parts of this, but focus on one task until that’s completed.

For getting `main` branch in sync, check out also the Steps `#1` and `#2` from [Contribute to the Codebase | Contribute | freeCodeCamp.org](https://contribute.freecodecamp.org/how-to-contribute-to-the-codebase/#contributing-to-the-codebase). After that’s done correctly, on Github page of your fork’s `main` branch, should be information that branch is either in sync, or is _behind_ of `freeCodeCamp/freeCodeCamp:main`.

If there are some errors while trying to do it, please share them.

---

<div class="post-metadata">

**Author:** ![stephenmutheu](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/stephenmutheu/32/421476_2.png) [@stephenmutheu](https://forum.freecodecamp.org/u/stephenmutheu)\
**Post date:** [January 10, 2025, 6:18am UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/5 "2025-01-10T06:18:07Z")

</div>

I have divided the problem into chunks. The first chunk is to solve the "filename too long " problem which is preventing me from switching branches.  
I have tried resolving it by enabling the `Enable Long Path Support:` on my computer but it did not work.

I decided to configure git to accept long names using this command `git config --system core.longpaths true` but permission was denied.

My main branch is ok, I did allow syncing so that I’m not behind by commits, and I’m confident I can now resolve the issue if I can switch between branches.

---

<div class="post-metadata">

**Author:** ![sanity](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sanity/32/378897_2.png) [@sanity](https://forum.freecodecamp.org/u/sanity)\
**Post date:** [January 10, 2025, 7:21am UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/6 "2025-01-10T07:21:56Z")

</div>

From what I’m finding `git config --system core.longpaths true` needs to be run as administrator. Otherwise removing the `--system` or replacing it with `--global` might work.

Are you running it in WSL? The native development on Windows is not supported by freeCodeCamp.

One more clarification regarding the `main` branch - if on Github it’s written that branch is _ahead_ of `freeCodeCamp/freeCodeCamp:main`, then that’s not correct.

---

<div class="post-metadata">

**Author:** ![stephenmutheu](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/stephenmutheu/32/421476_2.png) [@stephenmutheu](https://forum.freecodecamp.org/u/stephenmutheu)\
**Post date:** [January 10, 2025, 7:37am UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/7 "2025-01-10T07:37:20Z")

</div>

> [@sanity](#):
>
> Are you running it in WSL? The native development on Windows is not supported by freeCodeCamp.

This is the source of my woes; I am running it on Windows 🤦‍♂️ That is why I have had dependencies compatibility problems with other codebases.

I need to fix this first. Thank you. The articles were useful.

---

<div class="post-metadata">

**Author:** ![sanity](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sanity/32/378897_2.png) [@sanity](https://forum.freecodecamp.org/u/sanity)\
**Post date:** [January 10, 2025, 7:44am UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/8 "2025-01-10T07:44:38Z")

</div>

Contribute page has another article regarding using WSL, see [Set up freeCodeCamp on Windows Subsystem for Linux (WSL) | Contribute | freeCodeCamp.org](https://contribute.freecodecamp.org/how-to-setup-wsl/)

---

<div class="post-metadata">

**Author:** ![stephenmutheu](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/stephenmutheu/32/421476_2.png) [@stephenmutheu](https://forum.freecodecamp.org/u/stephenmutheu)\
**Post date:** [January 10, 2025, 7:56am UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/9 "2025-01-10T07:56:10Z")

</div>

I had plans to migrate to Ubuntu, it will be a better idea. I have worked with Kali Linux before.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [July 11, 2025, 7:56pm UTC](https://forum.freecodecamp.org/t/removing-commits-from-a-pull-request/729017/10 "2025-07-11T19:56:26Z")

</div>

Closed on July 11, 2025, 7:56pm UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
