Question:
I am learning git while working on an application.
At the moment I have a master branch and another hotfix branch.
While working on the hotfix branch, I noticed that in one of the previous commits, I forgot to add some data to one of the files.
You can, of course, add them now, and just make a commit with these changes, but for purposes of study, I would like to change the old commit in which this file was added.
Final goal:
- modified a file that was added in an old commit
- this file, in modified form, was added to this old commit
- in all subsequent commits in this branch, the changes are visible
- pushed to github
How to work properly in such a situation?
Answer:
To change NOT the last commit, run:
git rebase --interactive
Source .