在做git-svn dcommit之前压缩或编辑一些提交? [英] Squashing or editing some commits before doing git-svn dcommit?

查看:147
本文介绍了在做git-svn dcommit之前压缩或编辑一些提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用严格的签入策略处理Subversion版本库中的项目,其中包括:每次对干线的提交都必须由其他开发人员进行审阅,并且必须在提交消息中提及。

b
$ b

在使用git-svn时,我正在制作很多未经审查的增量git签入。他们的git提交消息反映了这一点。



使用git-svn的最佳方式是什么,但遵循svn存储库的规则?我应该只是将所有提交压缩为单个svn提交?我能否使用审阅者信息重写每个修订版的提交消息?我可以手动将每个单独的更改移动到git master分支,并在做git-svn dcommit之前修改每个分支的提交消息吗?

解决方案

您可以交互地将您的本地分支与Subversion跟踪分支重新绑定,从而为您提供挤压和修改提交的机会。



下一次您dcommit时,dcommit将一次重放您的历史记录,这将是Subversion的承诺。



假设:


  1. 本地分支是master

  2. li>
  3. 远程追踪分支名为git-svn

  4. git-svn是最新版本

做什么:

  $ git rebase -i git-svn 
code>

您的默认编辑器将打开一个主文件提交列表,用于重新绑定git-svn。您可以选择,编辑或挤压提交(如果需要,混合和匹配)。

完成选择后,另一个临时文件将打开显示您正在重写的每个提交的提交消息。这是您修改提交信息的地方。



注意事项:



您正在改写存储库的历史记录,谨慎行事。直到感到自信之前,试验这种行为可能是值得的。


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 must be mentioned in the commit message.

While working with git-svn I am making many incremental git check-ins that aren't reviewed. Their git commit messages reflect this.

What's the best way in which to use git-svn but follow the rules for the svn repository? Should I just squash all commits into a single svn commit? Can I rewrite the commit messages for each revision with the reviewer information? Could I "manually" move each individual change to the git master branch and modify the commit message of each before doing a git-svn dcommit?

解决方案

You can interactively rebase your local branch against the Subversion tracking branch which provides you with an opportunity to squash and amend the commit.

Next time you dcommit, dcommit will replay your history one commit at a time and this is what will be commited to Subversion.

Assumptions:

  1. Local branch is master
  2. Master is checked out
  3. Remote tracking branch is named git-svn
  4. git-svn is up to date

What to do:

$ git rebase -i git-svn

Your default editor will open with a list of commits in master to rebase against git-svn. You can pick, edit or squash the commit (Mix and match if desired).

After making your selection, another temporary file will open displaying commit messages for each of the commits you're rewriting. This is where you amend the commit message.

Caveats:

You're rewriting the history of your repository, exercise caution. It might be worthwhile experimenting with this behaviour until feel confident.

这篇关于在做git-svn dcommit之前压缩或编辑一些提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆