Commit / Merge / Rebase / Workflow / Squash
sha1(
commit date
commit message
committer
author
author date
tree
)
sha1(
commit date
commit message
committer
author
author date
tree
)
//Before | //After
A----B----C (develop/HEAD) | A----B----C----1----2 (develop/HEAD, project)
\ |
1-----2 (project) | //Before | //After
A----B----C----D----E (develop/HEAD) | A----B----C----D----E----F (develop/HEAD)
\ | \ /
1-----2 (project) | 1-----2 (project)//Before | //After
A----B----C----D (develop/HEAD) | A----B----C----D----$1----$2 (develop/HEAD,project)
\ |
1---- 2 (project) |
Should we work with merges or rebases ?
Defining a single and unique Git Workflow for all contributors is essential to ensure better collaboration and establish uniform contribution rules for everyone.
Merge - Rebase / master - develop - feat
The rebase --onto makes rebasing easier, even for the most complex cases, without the drawbacks of a standard rebase.
It also provides flexibility in reorganizing commits (removing, renaming, reordering, etc.)
//Initial state
A----B----C (main/HEAD)
\
D---...---Y---Z (develop/HEAD)
\
1---2---3 (project/HEAD)//Initial state
A----B----C (main/HEAD)
\
D---...---Y---Z (develop/HEAD)
\
1---2---3 (project/HEAD)//Rebase develop onto main
A----B----C (main/HEAD)
\
$D---...---$Y---$Z (develop/HEAD)
x (/This link is broken*/)
1---2---3 (project/HEAD)//Initial state
A----B----C (main/HEAD)
\
D---...---Y---Z (develop/HEAD)
\
1---2---3 (project/HEAD)//Rebase develop onto main
A----B----C (main/HEAD)
\
$D---...---$Y---$Z (develop/HEAD)
x (/This link is broken*/)
1---2---3 (project/HEAD)//Rebase project onto develop (without rebase --onto)
A----B----C (main/HEAD)
\
$D---...---$Y---$Z (develop/HEAD)
...\... (Try to find the oldest common ancestor*/)
1----2---3 (project/HEAD)
git rebase --onto <newparent> <oldparent> <feature-branch/until> |
//Before | //After
A----B----C----D (develop) | A----B----C----D (develop)
\ | \
1----2 (project/HEAD) | $1----$2 (project/HEAD)
git rebase --onto <newparent> <oldparent> <feature-branch/until> |
//Before | //After
A----B----C----D----E (develop) | A----B----C----D----E (develop)
\ | \
1----2----3----4 (project/HEAD) | $3----$4 (project/HEAD)$ git checkout project
$ git rebase --onto D C
//Before | //After
A----B----C----D (develop) | A----B----C----D (develop)
\ | \
1----2 (project/HEAD) | $1----$2 (project/HEAD)
git rebase --onto <newparent> <oldparent> <feature-branch/until> |
$ git checkout project
$ git rebase --onto D 2
//Before | //After
A----B----C----D----E (develop) | A----B----C----D----E (develop)
\ | \
1----2----3----4 (project/HEAD) | $3----$4 (project/HEAD)
git rebase --onto <newparent> <oldparent> <feature-branch/until> |
//Rebase project onto develop (without rebase --onto)
A----B----C (master/HEAD)
\
$D---...---$Y---$Z (develop/HEAD)
...\... (Try to find the oldest common ancestor*/)
1----2---3 (project/HEAD)//Rebase project onto develop
A----B----C (master/HEAD)
\
$D---...---$Y---$Z (develop/HEAD)
\
$1----$2---$3 (project/HEAD)
git rebase --onto <newparent> <oldparent> <feature-branch/until> |
//Rebase project onto develop (without rebase --onto)
A----B----C (master/HEAD)
\
$D---...---$Y---$Z (develop/HEAD)
...\... (Try to find the oldest common ancestor*/)
1----2---3 (project/HEAD)$ git checkout project
$ git rebase --onto $Z CURRENT_PARENT (or $git rebase --onto develop CURRENT_PARENT)
//Rebase project onto develop
A----B----C (master/HEAD)
\
$D---...---$Y---$Z (develop/HEAD)
\
$1----$2---$3 (project/HEAD)Squash consists of combining n commits into 1 relevant, understandable and coherent commit.
The goal of squash is to make Git history readable, clear and meaningful.
* e0d1c94 - 2022-09-30 (14 seconds)- feat(metier) sql create report request OK !!! (HEAD -> master)
* db37fe2 - 2022-09-30 (62 seconds)- feat(metier) oups!!! update 2 sql create report request
* 4f5e97f - 2022-09-30 (2 minutes)- feat(metier) update sql create report request
* 683d34b - 2022-09-30 (2 minutes)- feat(metier) add sql create report request
* 9ff0e10 - 2021-03-24 (1 year, 6 months)- chore(master) add .gitignore regenerate-*.bat$ git rebase -i HEAD~4 (ou git rebase -i 9ff0e10)* 78fd32c - 2022-09-30 (2 minutes)- feat(metier) add sql create report request (HEAD -> master)
* 9ff0e10 - 2021-03-24 (1 year, 6 months)- chore(master) add .gitignore regenerate-*.batReal-time evalutation of the return on time invested in following this presentation