简体   繁体   中英

How can I use GIT-TFS and GIT-SVN in the same source tree?

I have a project at work that I'd like to make needlessly complex easier by using git for my local source control. We use TFS at work, but I also have to push the source to the client's SVN server for production releases. TFS needs to be the official source of record [until I can make a convincing case to switch :-)], SVN is just milestones, and I'd love for git to be the day-to-day working environment.

I've been using git-svn for the second part, basically just committing to git at the milestones, then pushing to svn.

I'd like to move to using git instead of TFS for the more active development, too, but I'm not sure how/if I can have both mappings setup at the same time. All of the examples that I see for git-tfs and git-svn start with cloning the repository, which requires the repository to be empty. Is there some sort of metadata that I can add instead of cloning to setup the TFS mapping?

The mappings are also a little weird (it's a CMS site, so we don't store the core files in source control, only our customizations):

  • tags (only used by SVN)
  • branches (from SVN, not used)
  • trunk (from SVN, symlinked to Website)
  • Website
    • DesktopModules (mapped in TFS)
    • Portals (mapped in TFS)
    • Providers (mapped in TFS)

Will git be able to handle the SVN repository mapped at the root and the TFS repository mapped further in?

Would it work to delete the folders mapped in TFS, then clone them from git-tfs?

You can graft git-svn onto any repository by adding the appropriate stanza to .git/config (examine any working git-svn repo to see what it looks like) followed by git-svn fetch to populate it. It's unlikely that both git-svn and git-tfs will produce identical SHAs for identical trees (eg due to trivial things like username mapping or dates, or less trivial things like the metadata git-svn puts in commit messages by default) but the merges should be trivial. You can use svn.noMetadata to disable the extra line in each commit that maps the SVN revision to the git commit. The only downside to that is that the rev_map will be the only source of that information and if it is deleted (or if you clone your working copy) the git-svn connection will be broken.

I think that currently you can't. When you commit to tfs - git-tfs effectively rewrites your commit to the new one with the same tree and altered comment (appends something like git-tfs-id: [http://tfs:8080/tfs]$/Project;C666 to the end of original comments).

There were some thoughts about replacing comment altering with git notes . But it is not even in plans currently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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