Squashing or editing some commits before doing git-svn dcommit?

后端 未结 4 581
梦如初夏
梦如初夏 2021-02-09 06:49

I am working on a project in a subversion repository with a strict check-in policy which includes: Every commit to the trunk has to be reviewed by another developer and this mus

4条回答
  •  滥情空心
    2021-02-09 07:09

    I work in a branch on git, then checkout master, git svn rebase and finally merge the branch into master.

    At this point, git svn dcommit will put all the interim commits into svn one at a time with their original messages — not what's wanted! But if I use git commit --amend to change the merge's commit message from the standard merge message to something that fits our policy for svn commits, the dcommit will lump them all together as one under the new message. Win.

    I've found that this doesn't seem to work if master hasn't changed over the lifetime of the branch — the commits just get fast-forwarded in, with no "merged branch" message — so it's best add the --no-ff flag to git merge.

    Summary:

    git checkout branch
    
    git checkout master
    git svn rebase
    git merge --no-ff branch
    git commit --amend
    
    git svn dcommit
    

提交回复
热议问题