Using git in svn checkout? (without git-svn)

I performed a number of searches, but could not find the answer to this question. Sorry if this is a duplicate.

I would like to know if there are problems with initializing git repo (for local use) within the existing svn check, but without using git-svn .

Here is my scenario:

  • My team uses svn and is not familiar with git .
  • I am still involved in git ; I am not as familiar with it as with svn .
  • I would like to use powerful local git functions (e.g. branching, stashing, etc.).
  • I do not want to learn git-svn at this time (although I plan in the future).
  • I will use the svn client exclusively for interacting with the repository. (Therefore, I clearly understand what I am doing on the svn side and not getting any weird interactions).

I think I always did svn update and commit from the main git branch. When I work on functions, I would merge with and from the master.

Has anyone tried this? Are there any unpleasant flaws or side effects? Tips?

+4
source share
2 answers

TL DR: Yes, you can, but it's harder than just learning git-svn .

I tried. The main problem you are facing is converting svn up operations to Git. There are two approaches that I have seen:

  • Add your .svn folder to .gitignore , so you will never have Git Subversion metadata tracking. This means that you have Subversion and Git separately tracking your working copy, so any operation on one requires a similar operation on the other.

    If you don’t think about how you plan to use the repository, it’s very convenient to use Subversion merges, branches and switches and remember to use them carefully to match what you do with the repository using Git, you will lose most of the benefits of the Git branching model.

  • Track the .svn folder with Git. This means that if, for example, you performed svn up and git commit , and then retrieved the old Git commit, Subversion metadata will match correctly.

    This means that you can more easily use the Git branch functions, but there are many other problems with the presence of Git track Subversion metadata. The primary (at least for Subversion 1.6, I don't know, about 1.7) is that the empty folders in the .svn directory .svn significant, but Git does not track empty folders, so they will be deleted without warning.

I used Method 1 a bit, but found that it gave me all the worst bits of both Git and Subversion with very little advantage and meant that all operations had to be done twice in order to do something.

My colleague used Method 2 for some time with great success, but he wrote a whole bunch of helper scripts to let him do this. In particular, its scripts will scroll through a working copy and fix any .svn directories that needed to add empty folders. There was a lot of configuration work, but that meant that he could at least use most of the features of Git. Unfortunately, I do not have access to the scenarios in question.

Using git-svn for some time, I can vouch that it is simpler than any of these options, even as a Git beginner. I would recommend keeping a working copy of Subversion for cases where you need to do something now, and you don’t have time to check out the best way to do it with Git, or for cases where git-svn too limited to do what you need. The learning curve for git-svn , I would say, is not much more complicated than for regular Git, especially because you do not need to learn anything about working with a remote Git repository.

+5
source

I tried this, it can work. You just need to add the SVN files associated with your .gitignore and Git files to svn ignore. A similar question was also asked here , just replace StarTeam with SVN.

Actually not much to learn to go with git-svn. Your workflow will be basically (the rest of the article) :

  • create local git svn clone -s http://svnrepo repo: git svn clone -s http://svnrepo
  • get the latest data from svn: git svn fetch then git svn rebase
  • make local changes: git add and git commit -m "message"
  • push to svn: git svn dcommit

repeating steps 2-4 if necessary.

Not much to learn, and yet another tool for concern.

+1
source

Source: https://habr.com/ru/post/1446307/


All Articles