git-svn如何知道dcommit要使用哪个分支? [英] How does git-svn know which branch to dcommit to?

查看:111
本文介绍了git-svn如何知道dcommit要使用哪个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的回购是SVN,我使用git进行所有开发。我们有一个标准的布局,我用 git svn init -s< url to repo>



 #远程创建一个新分支
git svn分支新分支-name

#在本地切换到一个分支或中继
git reset --hard分支名称
git reset --hard trunk

#将主干中的更改合并到分支中
git reset -hard分支名称
git合并主干
git svn dcommit

上面的最后一条命令会将更改提交到分支名称分支。我的问题是,git如何知道这一点?当我做git reset --hard foo 时,到底发生了什么?

这可能只会归结为一般关于git的问题。每当我尝试研究一个答案时,我都会对svn整合是否是特例感到困惑。

$ c> git-svn 将查找对应于活动SVN分支的祖先提交的提交树( refs / remotes /...与SVN中的分支相对应的分支)。它会然后dmitmit这些。



请注意,你不应该合并,然后dcommit - SVN的和Git的分支模型不匹配,这种东西可以fubar您的SVN历史。当你在分支上时,你应该改为 git rebase trunk 。 (或者, git svn rebase 。)



另外,请注意您在重新绑定之前签出的分支应该是一个地方分支。如果不是,可以用 git checkout -b local-branch-to-create remote-branch 创建一个。然后 git rebase trunk



如果你想压缩所有提交的提交,这在rebase之后: git reset --soft trunk&& git commit



一旦您满意现在位于主干上的提交,只需 git svn dcommit 将它们推送到SVN服务器。


My repo is SVN, and I do all development with git. We have a standard layout, and I initialized my local repo with git svn init -s <url to repo>

Here's my workflow for working with branches:

# creates a new branch remotely
git svn branch new-branch-name

# switches to a branch or trunk locally
git reset --hard name-of-branch
git reset --hard trunk

# merge changes from trunk into a branch
git reset —hard name-of-branch
git merge trunk
git svn dcommit

That last command above will commit the changes to the branch name-of-branch. My question is, how does git know this? When I do git reset --hard foo, what exactly happens?

This might just come down to a general question about git. Every time I try to research an answer I get confused about if svn integration is a special case or not.

解决方案

git-svn will look up the commit tree for ancestor commits that correspond to active SVN branches (the refs/remotes/... branches that correspond to branches in SVN). It will then dcommit to those.

Note that you should not merge and then dcommit -- SVN's and Git's branching model do not match up, and this kind of thing can fubar your SVN history. You should instead git rebase trunk when you are on the branch. (Alternatively, git svn rebase.)

Also, be aware that the branch you check out prior to the rebase should be a local branch. If it is not, you can create one with git checkout -b local-branch-to-create remote-branch. Then git rebase trunk.

If you want to squash all of the commits that were rebased into one, then do this after the rebase: git reset --soft trunk && git commit.

Once you are happy with the commits that now live on top of trunk, just git svn dcommit to push them to the SVN server.

这篇关于git-svn如何知道dcommit要使用哪个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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