We have a master
branch and each developer has his own dev branch(not feature branch) for example dev-john
, dev-rahul
etc
Now john takes frequent pulls from master
to dev-john
and makes frequent commits to dev-john
He occasionally merges his commits on dev-john
into master
without closing dev-john
I need a git flow where all commits after the last merge are merged into master
as a single commit with a commit message
I have tried to explain what I need in the graphic below
could anyone advise the git commands to run at every stage of this flow
flow modify suggestions are also welcome
Assume the commit history for now looks like ( M
x for the merged commits, R
x commits are the common commits on dev-rahul
branch, D
x commits are the common commits on master
branch, J
x commits are the common commits on dev-john
branch):
…--------R1--------M3---R2---R3---R4---R5 dev-rahul
\ / \
…------D1---M2---D2--------M4---D3-------M6 master
\ / \
…---J3---M1---J4---J5---J6--------M5 dev-john
Then you can use below commands to squash the commits after (squash commits M4
, D3
and M6
into one commit, as the commit S
in below graph):
git checkout master
git reset --soft HEAD~3
git commit -m 'squash commit S for commits M4, D3 and M6'
And the commit history will be:
…--------R1--------M3---R2---R3---R4---R5 dev-rahul
\ /
…------D1---M2---D2------S master
\ \
| M4---D3
| | \
…---J3---M1---J4---J5---J6------M5 dev-john
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.