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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:25:36+00:00 2026-06-07T00:25:36+00:00

This is a common problem for me. I make five or so commits then

  • 0

This is a common problem for me. I make five or so commits then find that some debug code that became irrelevant or junk code from a prior used algorithm stays around. Amending them to HEAD doesn’t always make sense and making a new commit for a one-line late change feels disorderly.

The solutions I know of include the above and checking out the previous commit, branching, editing and merging again. This works fine, but I wonder if either a more idiomatic or elegant solution exists.

  • 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-07T00:25:37+00:00Added an answer on June 7, 2026 at 12:25 am

    You can use interactive rebase to go back and edit a specific commit, as long as rewriting history is okay (basically, as long as you haven’t shared the commits with anyone else/the public).

    To do so, first find the hash of the commit you want to edit. Then, tell Git to do an interactive rebase from the commit before it:

    git rebase -i <SHA>~1
    

    The ~1 is important – it tells Git to reference the commit before the SHA you specified.

    This will bring up an editor with a line for each of your commits starting with the one you want to edit. Change the pick for that commit to edit, then save and quit out of the editor.

    Git will apply that commit, and then pause. You can then edit the files to remove the debug code, git add them, and git commit --amend to edit the commit.

    Afterwards, use git rebase --continue to apply the other commits in order, ending up back where you started (but with a new set of commits that doesn’t have your debugging code).

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

Sidebar

Related Questions

This is a fairly common problem to which I have yet to find an
I feel like this is a fairly common problem, but I cannot find the
I am looking for a general and complete solution to this common problem! I
I feel like this is a common problem but nothing I've researched has worked
This is a fairly common problem, it probably has a name, I just don't
This seems to be a common problem, but I cant seem to fin a
This must be a common problem with a common solution. I have a lot
OK this is a very common problem but mine is a bit different and
This is a slightly original variation on a common problem. I have a fairly
this question is about style, because i think this is a very common problem

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.