Skip to content

Git history

Interact Mode

with -i command, git will open default editior interface

$ git rebase -i bb0c9c2

pick 382a2a5 add database settings
pick cd82f29 add cat 1
.
.
.

change pick syntax to reword, save and exit then, the changed commit will be edited by default editior

notice that changing the commit messages will also change the SHA-1 value of commit

Combine multiple commit

use rebase with -i can also combine multiple commit

$ git rebase -i bb0c9c2

pick 382a2a5 add database settings
pick cd82f29 add cat 1
.
.
.
change pick to squash will squish commits with prvious one

Split one commit into multiple one

just use git reset to split commit

Add commit between commit

first, rebase to the commit want to change

$ git rebase -i <sha-1>
change pick to edit modify commit

then, after fixing commit, use continue

$ git rebase --continue

Delete specific commit or change sequence of commit

simply edit sequence in git rebase -i editor with delete, we could use drop syntax or simply delete specific line

Revert

add another commit to remove previous one