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 8311767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:55:11+00:00 2026-06-08T19:55:11+00:00

I just made a commit and accidentally left in some files I should have

  • 0

I just made a commit and accidentally left in some files I should have removed. How can I undo this commit without losing any of the work? I want to undo that commit, go in and remove 2 files and then recommit all the changes.

Thanks!

  • 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-08T19:55:12+00:00Added an answer on June 8, 2026 at 7:55 pm

    You don’t need to undo anything. As long as you haven’t pushed the commit:

    git commit -a --amend -C HEAD
    

    will amend the commit you just made, keeping the same commit message, committing any updated or deleted (but not untracked new) files.


    so if i remove the files and then run that it will add it to the commit?

    Yes, and if you want to be super-safe you can git rm the files and drop the -a flag:

    git rm files/to/delete
    git commit --amend -C HEAD
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a git project. I just made a commit, then I deleted some
I have just made a new git repo. I created a couple of files,
I have just made a portlet with web service for liferay to learn how
I have an image which is just made of one color ? (it could
I just made a perfectly good commit to the wrong branch. How do I
I have a git branch (called v4), that was made from master just yesterday.
Someone forked a Github project of mine and made some changes. How can I
hi I have a scenario like this I made a chat program where a
I accidentally made 10 commits on branch testing when I intended to commit them
I made a big oops, and could use some help undoing it. We have

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.