Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8226737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:52:44+00:00 2026-06-07T15:52:44+00:00

I committed, but not pushed to repository, a file to a branch i.e. abc

  • 0

I committed, but not pushed to repository, a file to a branch i.e. abc. Now I want to remove it from this branch abc. How can I achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:52:45+00:00Added an answer on June 7, 2026 at 3:52 pm

    I’m assuming you want to obliterate the file from history, as if it never existed. If you just want to get rid of the file in future commits, then use git rm my-bad-file.txt and ignore the rest of my answer.


    If the file is only in your most recent commit, then it’s easiest to use git rm my-bad-file.txt to remove the file, then git commit --amend to edit the previous commit.

    If there are several commits containing the offending file, then git filter-branch might be useful.

    git filter-branch --index-filter 'git rm --cached --ignore-unmatch my-bad-file.txt' master..abc
    

    This means:

    • git filter-branch: Let’s rewrite some commits!

    • --index-filter: Change each commit’s index without actually checking it out on disk.

    • 'git rm --cached --ignore-unmatch my-bad-file.txt': For each commit, unstage the file named “my-bad-file.txt” if it exists.

    • master..abc: Do this on all commits on branch abc back to where it forked from the master branch.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i read that upon session.flush() The data will be synchronized (but not committed) when
I have committed several files on GitHub but I want to pull only single
I have committed to learning C now, I'm good with Python/PHP/Bash but I've decided
My colleague has committed twice on his repository on the wrong branch. What is
I searched internet and SO but could not get solution to this issue. I
I'm not sure if this is an odd setup to begin with, but here's
I understand that git diff compares a staged file and modified but not staged
I have a file that I should have committed but forgot all about. I
I've committed a bunch of changes onto the master branch of my git repository,
This is probably quite a newb question, but I can't seem to figure it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.