git

Keeping git history clean

git rebase -i 95eeee3^

Rebase

git rebase helps maintain repository’s homeostasis or in other words helps maintain history clean.

git rebase -i 95eeee3^ -i begins an interactive rebasing session

Interactive mode will bring the following list of commands:

p, pick = use commit
r, reword = use commit, but edit the commit message
e, edit = use commit, but stop for amending
s, squash = use commit, but meld into previous commit
f, fixup = like "squash", but discard this commit's log message
x, exec = run command (the rest of the line) using shell
d, drop = remove commit

95eeee3 is the commit we want to modify

we can find it by doing: git log ^ means start modifying just before the specified commit

example

To modify a commit message and update some files:

git rebase -i 95eeee3^

change pick to edit (or just e) git reset HEAD~

update some files … git add -A . git rebase --continue

force push the change to the remote git push --force

Subscribe to The infinite monkey theorem

Get the latest posts delivered right to your inbox