Development is an iterative process, you constantly change your code after better understanding of business/requirements. git rebase is the mean to do these changes.
Devs hate to write docs: No more java docs, no more UML docs ... Only documenation that is left is ..........
The COMMIT MESSAGE (provide context to the code change for future dev(including yourself)).
What is a good commit message
(http://chris.beams.io/posts/git-commit/)
- subject : 50 chars (If applied, this commit will ----)
- blank line
- more description on the title if it was not explicit enough something 50 chars is not enough
- problem statement (Most important) / hafira is recommended here describe the context in details WHY and not HOW
What I like to add
-
(My personal fav list of responsibilities of each class) (if a class name and the responsibility do not align, if not single resp principle respected , you will spot it here)
-
(flow of types for scala ) (if the types can be simplified will also be spotted here)
-
IO chart : rabbit -> kafka -> rabbit
-
complex scenario involving events and time snooze -> unsnooze -> snooze ....
-
Resolves JIRA: #123
-
See also JIRA : #456, #789
- Use git web (https://github.com/motemen/git-browse-remote) to check you last commit in github, pretend you are the reviewer and see if anything bothers you or is out of place
- Work around github horrible PR features (no commit specific review, looses comments after rebase , ...)
- [PR-FIX] - prefix PR fixes commits and add them after the appropriate commit
- Make sure to check both main thread and each commits
Before you write any code open up a file and write your ideal commit log (target commit log) for the feature you are going to do
- Design features with cdd (commit driven design)
- Split your feature in logical changes
- Each commit receives its title no more than 50 chars
- check that your commit is not too fat , split if needed
- Fill in the problem statement part, Explain the problem that this commit is solving Focus on why not how
- What goes in a commit . i.e (Structural split of changes)
- Only one "logical change" per commit smaller the amount of code being changed, the quicker & easier it is to review & identify potential flaws.
- reformat only commit (if file was badly formatted before)
- retrofit refactoring (future -> past ) (use rebase e and intellij local history) 2a. pushdown refactoring (past -> future) overwrite with old commit using intellij get (commit and then use local history to resurect the change isolate the refactoring in its own commit , move it to where it should be)
- split fat commits : rebase e , reset --hard HEAD
- move code from one commit to another one (use git add interactive and patch)(gitx)
- PR fix commit with rebase e and git commit --amend
- Add a temp commit the beginning (enable debug logs/ various speedup for dev) that will be deleted after final review
- resolve rebase merge conflicts with Intellij and local history
- abort when it's too hard
- use rebase execute to make each commit compile/test independently
- split test commits to their own (more important than it looks like)
Will show my regular flow here
-
Each commit should provide executable value, you should be able to deploy to robin after each commit and validate your change there, sometimes it means adding a code that exercise your change and that will be removed in a later commit (should usually happen in long features and in the early commits) (Having executable code running in staging after each commit allows to spot faster implementation errors and fix them fast)
-
Run Fast, commit even if your not happy with the solution prefix the commit with [WIP], progress as fast as possible to the end of your target commit log . (reaching the end of your target log even in [WIP] let you spot all the design flaws and fix them fast)
-
Go back and use
rebase e
to edit and move your [WIP] commits to production grade commits .
.gitconfig
# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
name = Daniel Sebban
email =
[core]
editor = subl -n -w
[alias]
r = rebase -i develop
fixup = "commit --fixup HEAD "
auto = "git rebase -i develop --autosquash "
squash = rebase -i develop --autosquash
grog = log --graph --abbrev-commit --decorate --all --format=format:\"%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(dim white) - %an%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n %C(white)%s%C(reset)\"
fsquash = commit --fixup HEAD && rebase -i develop --autosquash
web = browse-remote --rev
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
stat = log --stat --oneline
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
ld = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
le = log --oneline --decorate
dl = "!git ll -1"
dlc = diff --cached HEAD^
f = "!git ls-files | grep -i"