将本地 Git 提交合并为 git-svn 的一次提交
目前,当我运行 git svn dcommit 时,git 会在 SVN 中为自上次与 SVN 同步以来所做的每个本地提交创建一个单独的提交。有没有办法让 dcommit
将我最近的所有本地提交合并到 SVN 的一个提交中?
Currently, when I run git svn dcommit
git creates a separate commit in SVN for every local commit I've made since last syncing with SVN. Is there any way for dcommit
to instead combine all my recent local commits into one commit for SVN?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
应该会带您进入菜单,您可以在其中选择提交或将它们全部压缩为 1 个提交,以避免污染您的 svn 存储库。 这是一个非常好的(但简短的)工作资源使用 git-svn。
should bring you to the menu where you can pick commits or squash them all into 1 commit in order to avoid polluting your svn repository. This is a really good (but short) resource on working with git-svn.
不,但是您可以轻松地将所有提交压缩在一起。对于以下示例,我假设您位于与远程
trunk
分支相对应的master
分支上,并且您希望将所有本地提交压缩在一起:使用临时标记时,您也可以只使用引用日志(即使用
master@{1}
代替local
)No, but you can squish all the commits together pretty easily. For the following example, I'm going to assume you're on the
master
branch corresponding to the remotetrunk
branch and that you want to squish all local commits together:Instead of using a temporary tag you could also just use the reflog (i.e. use
master@{1}
in place oflocal
)当我使用 git-svn 并希望一系列 git 提交显示为单个提交时,我会处理一个主题分支,然后在
之前执行非快进
-ing。合并
到 master 中>dcommit首先,根据 svn 重新调整您的分支并确保本地 master 是最新的:
然后切换到 master,合并并提交:
这将在 Subversion 中显示为单个提交,但您仍然会拥有本地历史记录那个承诺。
When I work with git-svn and want a series of git commits to show up as a single commit, I work on a topic branch and then do a non-fast-forward
merge
into master beforedcommit
-ing.First, rebase your branch against svn and make sure local master is up-to-date:
Then switch to master, merge and dcommit:
This will show up as a single commit in Subversion but you will still have your local history that got you to that commit.
一种更简单的方法可能是(如果您的本地系统上堆积了多个提交):
A simpler way could be (if you have multiple commits piled up on your local system):
这对我有用——将多个提交压缩为一个提交,然后提交到 svn:
This worked for me--squashed several commits into one commit and then dcommitted to svn:
http://www.gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
那对我不起作用。我使用
merge --no-ff --no-commit
但提交后,我得到:dcommitting to trunkwill commit all 336 commits。
如答案#2中所述重置、标记和压缩: 将本地 Git 提交合并为 git-svn 的一个提交 可以,但是在下一次“合并”时,您将遇到一些麻烦,无法再次将所有提交合并在一起!
唯一对我有用的方法:
从 master 到 svn 的所有提交都不会丢失历史记录,以便将来使用相同的命令合并
~Marcel
that is not working for me. I use
merge --no-ff --no-commit
but after commit, I got:dcommitting to trunkwill commit all 336 commits.
resetting, tagging, and squashing as described in answer #2: Combine local Git commits into one commit for git-svn will work, but on next "merge" you will have some trouble to get all commits together again!
the one and only that is working for me:
to get all commits from master to svn without loosing history for future merging with the same command
~Marcel