git svn 并与私人分支机构合作?

发布于 2024-12-07 17:41:34 字数 989 浏览 1 评论 0原文

这里是新的 git 用户。我想使用git,但我在SVN环境中。从我读过的一些书和一些简单的实验中,我遇到了一些令人不安的陷阱,我希望得到关于如何开始的澄清,而不会让我的同事想杀了我。

我希望我的工作流程是:

  • 一个与 svn 的主干保持同步的主 git 分支。

  • 我在其中执行功能和错误工作的本地 git 分支。

  • 我想经常使功能分支与 master 保持同步。

  • 当我准备好时,我想将一个功能分支与 master 合并并将其提交回 svn。

这是典型的工作流程吗?

最初我使用 git merge 来合并我的主分支和功能分支。这导致了各种各样的冲突和问题。后来我读到避免使用 git merge 并坚持使用 git rebase。那么,以下 git 命令是否正确?

  • git svn rebase (将最新更改拉到 master 上)
  • git checkout -b myAwesomeFeature (使功能分支可以工作)
  • ... 做一些工作,提交到我的功能分支
  • <<<时间流逝>>>
  • git checkout master
  • git svn rebase (拉下新东西)
  • git checkout myAwesomeFeature
  • git rebase master (将 svn trunk 的东西放入我的功能分支)
  • <<<准备好推送我的功能分支>>>
  • git checkout master
  • git rebase myAwesomeFeature (快进大师头以获取我的功能内容)
  • git svn dcommit (最终发布)

任何帮助有抱负的 git 用户生活在 svn 世界的建议或建议将非常感激。谢谢

new git user here. I want to use git, but i'm in an SVN environment. From some books I've read and some simple experimenting, I've hit some troubling pitfalls and am hoping to get clarification on how to get starting without my colleagues wanting to kill me.

I want my workflow to be:

  • a master git branch that stays in step with svn's trunk.

  • local git branches that i do my feature and bug work in.

  • I want to frequently bring the feature branches up to date with master.

  • When i'm ready I want to merge a feature branch in with master and commit that back to svn.

Is this a typical workflow?

Initially I was using git merge to merge my master branch and feature branches. This led to all kinds of conflicts and problems. I later read to avoid using git merge alltogether and stick with git rebase. Would the following git commands, then, be correct?

  • git svn rebase (to pull down latest changes to master)
  • git checkout -b myAwesomeFeature (to make a feature branch to work on)
  • ... do some work, make commits to my feature branch
  • <<< TIME GOES BY >>>
  • git checkout master
  • git svn rebase (to pull down new stuff)
  • git checkout myAwesomeFeature
  • git rebase master ( to get svn trunk's stuff into my feature branch)
  • <<< READY TO PUSH MY FEATURE BRANCH >>>
  • git checkout master
  • git rebase myAwesomeFeature (to fast forward masters head to get my feature stuff in)
  • git svn dcommit (to finally publish)

Any advice or suggestions to help an aspiring git user live in an svn world would be really appreciated. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹微笑 2024-12-14 17:41:34

你的工作流程和我的差不多。如果您只提交到 svn trunk 就足够了。当你提交到多个 svn 分支时,事情会变得复杂,其中 rebase 不仅会合并内容,还会更改指向的 svn 分支,在这种情况下,你只能在需要提交时使用 gitcherry-pick进入一个 svn 分支,目标是另一个 git 分支,如下所述:克服git svn 警告

还值得理解的是,SVN 无法处理非线性历史记录,并且 git merge 不能与它一起使用:git svn 工作流程 - 功能分支和合并

Your workflow is about the same I have. It is good enough if you are only committing to the svn trunk. It gets complicated when you commit to multiple svn branches where rebase not only merges the contents, but also changes the pointed-to svn branch, in which case, you can only git cherry-pick when you need commits into one svn branch targeting git branch in another, as discussed here: Overcome git svn caveats

It is also worth understanding that SVN's inability to handle non-linear history and that git merge can't be used with it: git svn workflow - feature branches and merge

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文