1.2 KiB
Rewrite Git History
Changing the Last Commit
If you want to modify your last commit message:
git commit --amend
Rewrite multiple Commit
for that you need to use rebase in interactive mode like this:
git rebase -i HEAD^3
this will open an editor wit list of commit you need to modiy this with needed action to do
Reordering Commit
ON this editor you can invert line to change commit order, git will reaply commit in wew order
Squash & fixup commit
Squash option will merge will merge xommit with the previous and ad commit message in the new commit message
Fixup do same thing put forgot commit message
Splitting a Commit
you can do that with edit command
git rebase will stop after apply commit where you hae put edit
ad this moment you can process to a Head reset and commit when you want to add commit modification like ewample below
git reset HEAD^
git add README
git commit -m 'Update README formatting'
git add lib/simplegit.rb
git commit -m 'Add blame'
git rebase --continue
delete
drop will delete comite rebase will not apply modification during processing to use by example if you have done a modifcation and a revert