I want to fix a file in past commit. This might affect all ascending commits.
Is there an easy way to do that?
Many times when I commit twice I find that I’ve had error in the first commit, and I wish to fix the error without having to git reset my last good commit.
For clarification, I want to change the actual commit, that is, I want the content of the past commit to be changed. In other words, I want to change history!
If you only want to amend the second to last commit (eg. not long ago, especially not before many branches and merges), then I use this procedure:
git checkout -b tmp bad-commitgit commit --amendgit rebase tmp masterIf you have merges in between, you may wanna try
rebase -i -p, but the results may vary.