-1

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?

akond
  • 15,865
  • 4
  • 35
  • 55
ratojakuf
  • 708
  • 1
  • 11
  • 21
  • Have you tried http://stackoverflow.com/questions/215718/reset-or-revert-a-specific-file-to-a-specific-revision-using-git?rq=1 ? – Яois Mar 19 '15 at 22:16
  • @KeillRandor: Sounds like an interactive patch would be better. – Makoto Mar 19 '15 at 22:33

1 Answers1

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