I have data in the working directory for several future commits but i made mistake in some commit because it contains a line which must be in the future commit. So how can i delete that line from commit and return it to the working directory for next commit?
Asked
Active
Viewed 190 times
1 Answers
1
First:
git rebase -i target_commit_hash^
and edit the commit, unstage wanted line (git reset HEAD -p
) and amend the commit. Then stage the file with this one line and save in a separate commit. After that continue the rebase.
Then do rebase again:
git rebase -i target_commit_hash^
and move the commit with your one line to the top of the tree.
Then:
git reset HEAD^
this will remove the temporary commit with your one line and make this line as unstaged.

phts
- 3,889
- 1
- 19
- 31