Alias git commit
to git ci
Alias git status
to git st
Alias git diff --cached
to git dc
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.dc "diff --cached"
git st
displays those changes
add in patches interactively, hint: be selective
git add -p path
I use s
and e
options a lot while reviewing the changes for staging
in the e
edit mode
- to cancel staging removed lines marked with '-': replace '-' with ' '
- to cancel staging new lines marked with '+' either remove or comment them
Note: to comment multiple lines in nano (the default editor) follow this stack overflow answer
git dc
to review the changes for a commit
If any change wasn't meant to be added, reset it with git reset -p path
, that resets in hunks too
For complete commit messages use
git ci
For inline commit messages (just a header with no body)
Note: that is useful in case multiple comits are following with subtle change in commit message.
git ci -m "Commit message"
Don't use -a
on git ci
by default!
Make your fixes, stage them, then git ci --amend
.
Note: Commit message are prombted to be changed after while amending.
Another Note: the commit hash changes based on this step
git push origin branch_name
Caution: If you reached this point, there's no turning back "messing with everybody's history isn't something good"