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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:31:36+00:00 2026-06-15T21:31:36+00:00

I’ve taken a look at these previous questions already: Howto add a changed file

  • 0

I’ve taken a look at these previous questions already:

  • Howto add a changed file to an older (not last) commit in Git
  • How do I edit a previous git commit?

They don’t exactly address a particular issue though – there are other changes in the index! When running the rebase command, git complains: Cannot rebase: You have unstaged changes.

Scenario:

The commit previous to the last one (do I refer to that as "2 HEADs ago"?) was a refactor commit. I currently have in the index many unstaged changes, but only some of which I want to add to the previous to last commit.

I’m imagining the way to do this would be to:

  1. stash all of my current changes
  2. rebase -i to the previous to last commit (changing index and moving Head, right?)
  3. load the stash into my index without changing Head (how?)
  4. use add -p and commit --amend to selectively modify this old commit
  5. rebase --continue to finish (updates children, moves Head back to where I started, what happens to index?)
  6. then pop/clear the stash (index back to where I started).

Is this correct? If it is, how do I do step 3? If it isn’t, what should I be doing instead?

Also, note that I’m still learning about git and am still not 100% sure I’m referencing things in git (Head, index, stash, etc) properly.


Solution:

For anyone else this may help, these are the steps I actually took:

  1. git stash all of my current changes
  2. git rebase -i <ID> to the parent of the previous to last commit, changing index and moving Head
  3. git stash apply load the stash into my index without changing Head
    • if you have conflicts, git reset HEAD <file> to unload files staging. Make sure staging is clear.
  4. use add -p and commit --amend to selectively stage changes and commit them
  5. git reset --hard to discard index so it matches Head
  6. git rebase --continue to finish. updates children, moves Head back to very start, but with changes
    • history is now forked into two versions. The other branch ends at the WIP previously stashed
  7. then pop the stash to bring index back to where I started. The other branch is also cleared.
  • 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-15T21:31:37+00:00Added an answer on June 15, 2026 at 9:31 pm

    Your plan sounds good. A git stash apply or git stash pop will modify the working tree and/or index, but will not change HEAD, so you should be able to do it while in a rebase edit.

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

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I know there's a lot of other questions out there that deal with this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you

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.