简体   繁体   English

Subversion 存储库中的 Git 工作副本

[英]Git working copy within a Subversion Repository

I have a project at work, and we use Subversion to version control everything.我有一个工作项目,我们使用 Subversion 对所有内容进行版本控制。 However, we have a client for a particular project who has used Git for something I need to check out and put in our project repository.但是,我们有一个特定项目的客户,他使用了 Git 来做一些我需要检查并放入我们的项目存储库的东西。 Normally I would just check out the Git repo, export it into my SVN working copy, version the files, and be done with it.通常我只会查看 Git 存储库,将其导出到我的 SVN 工作副本,版本文件,然后完成它。 However, the guy regularly updates this code, and I need to stay near where he is at.但是,这家伙会定期更新此代码,我需要留在他所在的位置附近。

What would happen if I just check out the Git repository into my SVN working copy and version the files?如果我只是将 Git 存储库检出到我的 SVN 工作副本和版本文件中,会发生什么?

NOTE Git-svn is not an option, I have never used it and unfortunately I don't have time to learn something new for this.注意Git-svn 不是一个选项,我从未使用过它,不幸的是我没有时间为此学习新东西。

Just clone the Git repo.只需克隆 Git 存储库。 Nothing bad would happen and you will be able to update that code by doing git update .不会发生任何不好的事情,您将能够通过执行git update来更新该代码。 You can safely commit a git repo into subversion, I have done it before.你可以安全地将 git repo 提交到 subversion 中,我以前做过。

There aren't any technical problems with this, but it will wind up being a hassle.这没有任何技术问题,但最终会很麻烦。 Every time you make a change, you will need to commit it to Git, then add all of the new files that were created in the Git repository to Subversion, then commit all of that to Subversion.每次进行更改时,都需要将其提交到 Git,然后将在 Git 存储库中创建的所有新文件添加到 Subversion,然后将所有这些文件提交到 Subversion。 When you merge any of his changes in, you'll need to do all of that as well.当您合并他的任何更改时,您也需要执行所有这些操作。

One question I have is why would you want to do this;我的一个问题是你为什么要这样做? what benefit do you gain from having it in Subversion?在 Subversion 中使用它有什么好处? If you're going to need to merge changes with his upstream repository, then you'll need to learn Git anyhow.如果您需要将更改与他的上游存储库合并,那么无论如何您都需要学习 Git。 At that point, you might as well just use Git to do your version control, and not complicate things by trying to integrate with Subversion.此时,您不妨只使用 Git 来进行版本控制,而不是通过尝试与 Subversion 集成来使事情复杂化。 If you're just going to send him the final code, and let him integrate it, then why bother checking the Git repo into Subversion?如果您只是要将最终代码发送给他,并让他集成它,那么为什么还要将 Git 存储库检查到 Subversion 中呢? Just do what you normally do, check the current copy into Subversion, work on it, and then send him the final result when you're done.做你通常做的事,将当前副本检查到 Subversion 中,处理它,然后在完成后将最终结果发送给他。

git-svn would be useful if the official upstream copy of the code were in Subversion, but you wanted to work on it using Git because you prefer Git.如果代码的官方上游副本在 Subversion 中, git-svn会很有用,但您想使用 Git 来处理它,因为您更喜欢 Git。 It is not all that helpful for working with an upstream project that is managed in Git when you want to work with Subversion tools.当您想使用 Subversion 工具时,使用 Git 管理的上游项目并不是很有帮助。

Your proposed solution should work as git and svn have different meta files, and as long as you don't add the metafiles for one version control system into the the other, there is no conflict between them.您提出的解决方案应该作为 git 和 svn 具有不同的元文件,只要您不将一个版本控制系统的元文件添加到另一个版本控制系统中,它们之间就没有冲突。

Note, though, that whenever you change your files you will have to add them to both git and subversion, and thus you will have to deal with two different file control systems.但是请注意,无论何时更改文件,都必须将它们添加到 git 和 subversion,因此您将不得不处理两个不同的文件控制系统。

As you hint, using git-svn would help you, as it would allow you work with git only and then use git-svn to synchronize with your central svn repo.正如您所暗示的,使用 git-svn 会对您有所帮助,因为它只允许您使用 git,然后使用 git-svn 与您的中央 svn 存储库同步。 I'm doing this at work, and it is very simple to do and it works flawlessly (most of the time).我在工作中这样做,这很简单,而且它完美无瑕(大部分时间)。 I would consider learning it, I were you.我会考虑学习它,我是你。 You will have to learn git in any case to work efficiently with the client, and learning git-svn is relatively simple.无论如何,您都必须学习 git 才能有效地与客户端合作,而学习 git-svn 相对简单。 You basically just three commands:你基本上只需要三个命令:

  • git svn fetch - to get the latest svn changes to your repo git svn 获取 - 获取最新的 svn 对您的存储库的更改
  • git rebase git-svn - to incorporate the svn changes git rebase git-svn - 合并 svn 更改
  • git svn dcommit - to commit to the svn repo git svn dcommit - 提交到 svn repo

Learning git is well worth it, as in the end, I find it vastly superior to svn.学习 git 是非常值得的,因为最后,我发现它比 svn 好得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM