Are there any reasons I can't just use git to

2020-04-27 13:30发布

问题:

I have gotten used to using git on some of my home projects and work projects to track the changes I make in my own folders. I would like to use it to track the changes I make to a set of files in an svn checkout.

I have read about git-svn and it just seems like it is more than I want/need at this point.

I think all I really want to do (at this point) is to use git to track changes to a set of files / directories that just "happen" to be an svn checkout.

I am thinking I would even include the .svn directory in git as well (but not include the .git directory in svn). The idea being if I switch back to an old branch, my checkout would be exactly the same as it was when I last left it.

This seems like a strait forward approach to me, is there some specific reasons this would not work?

回答1:

I do this too. I turn an svn checkout to an independent git repo at the same time. However, I don't include the .svn directories and I think you shouldn't.

The practical advantages I'm using every day:

  • git ls-files | grep file-im-looking-for
  • git grep something-im-looking-for
  • Local experimental branches

These are really serious benefits for me over a simple Subversion checkout.

Why not use Git in the first place without Subversion? I have no control over the repository owner, so don't really have a choice. And git-svn is too fragile with large repositories.

Finally, I add .gitignore to the Subversion repository, and mark the .git folder ignored. This is practical for my colleagues who also do this kind of thing. I'm also sort of counting on other developers to see such Git related stuff in the Subversion repository, I hope to make them wonder, and possibly fuel my agenda of migrating the repo to Git.



回答2:

I've tracked largeish, very active SVN repositories (Dungeon Crawl Stone Soup, if you absolutely need to know) for a long time, no trouble at all. Didn't do anything in the direction of pushing changes, though, just used git to pack up my (minor) patches to report on their bug tracker. Only problem was that the initial clone took more than a day, IIRC. But then they migrated to git a while back...



标签: git svn