Reputation: 570
Usually I'm editing old commits with git rebase -i HEAD~<number of commits I added>
put edit
on the commits I want to edit, make the change, adding files and git rebase --continue
.
Is there a way to edit commits with rebase but to see the past commit changes? it will be much easier to spot the places I want to fix there, VScode mark the lines for me.
example:
let's say I have committed commitA
, commitB
, commitC
(HEAD at commitC).
now I would like to edit commitA. I'm git rebase -i HEAD~3
and put edit
on commitA. now I'm in the middle of my rebase but I want commitA
changes to appear as changes, the situation is making me write my fix when commitA
changes are already committed.
if there is an alternative way of fixing past commit and having that commit changes as staged
that would be great.
Thanks in advance!
Upvotes: 11
Views: 4160
Reputation: 570
o.k seems it's easier than I thought! just follow those steps: let's say I want to edit 5 commits back:
git rebase -i HEAD~5
git reset HEAD~1
since the commit already there, were just resetting it.git add <files of your change and past commit files>
or just git add -u
to add all tracked files.git commit
git rebase --continue
happy gitting :)
Upvotes: 12