简体   繁体   中英

Git: squash merge with DAG

I'm trying to use the Gitflow Workflow which I first met reading the comparison of workflows at Atlassian . The main idea is that the development is done on the develop branch which contains all the modifications merged from feature branches, and after that we merge develop into master . This way feature branches never interact directly with our master .

What I would like to achieve is to have a clean history on the master branch with only release commits . So new commits should be added there only at version changes, but still I would want to see the location of the merge on the git tree. Ordinary merges usually take some of the commits with themselves and several commits appear in the history instead of just one new commit. Squash merges are able to solve the problem, they squash all the changes into one commit, however, they mess up my git tree, because squash merges don't end up with merge commits but ordinary commits which have only one parent not showing the connection between the two branches. (This fools GitHub into thinking master is behind develop as well.)

I want the history of master look like this: 主

The history of develop : 开发

Git tree: git树

Is there a way to have squash merges with two parents creating a DAG ( Directed Acyclic Graph ) and connecting the two merged branches, meaning that my git tree would show me at which point was the develop (or the release ) branch merged into master ?

Oridinary merge is just what you ask - squashed changes with the link to source branch. If you don't want to see the merged commits you only need to request for it. You can provide --first-parent argument to git log command and it will not output them:

git log --first-parent origin/master

PS: the feature is supported by bundled gitk , also by sourcetree/macos and gitextensions . It is not by my knowledge implemented by public web services but for "bitbucket server" paid standalone server should be plugins which do this.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM