Search code examples
gitsvnazure-devopsgit-svn

GIT SVN - Use SVN for Development and GIT for Release Important Milestone


We have team (Team A) of 10+ members, they change the code frequently and commit to SVN.

Another team (Team B) is using GIT (Azure DevOps).

We need to push source code (from SVN) changes at certain point of time (e.g. monthly once) to GIT.

Use Case: If relese is done by Team A in JAN, and pushed source code into GIT. In FEB, we should push difference of source code between JAN and FEB release to GIT.

We want to keep Team A working on SVN and Team B to work on GIT.

How this can be achieved in seamless way ?


Solution

  • It should be pretty straight forward to do what you want:

    1. In the Git repo, checkout (switch to) the branch you wish to commit to, and make sure your status is clean with no pending changes.
    2. Optional: checkout a fresh copy of the SVN repo so that no build artifacts exist in what you're about to copy.
    3. Copy all of the files from the SVN repo into the Git repo in place.
    4. Optional: update the .gitignore file(s) to exclude files you don't with to track in the Git repo.
    5. At this point Git will show only the changes since the last time you did this process. Stage the files you wish to commit, and commit them with a sensible message.

    Repeat these steps anytime you want to take the latest SVN snapshot and commit it in Git (e.g. once per month as you suggested).

    Regarding the optional steps: You probably need to do either step 2 or 4, but maybe not both. If you ever intend to build anything in the Git repo that came from the SVN repo, then you'll probably want to do step 4 regardless. The goal here is that after the copy/paste in step 3, that you can blindly commit all the changes in step 5 without manually staging a subset.

    Side Note: regarding this sentence of your question:

    In FEB, we should push difference of source code between JAN and FEB release to GIT.

    SVN (and most source control tools) stores changes or diffs behind the scenes, however, Git works differently. Git stores snapshots of the entire repo in every commit, and behind the scenes it does compares to figure out a way to efficiently store those snapshots. This doesn't actually effect the answer, but it's an important concept to realize. Git calculates diffs on the fly when comparing commits to show you what changed between them.

    Additional Note: there are tools for converting SVN to Git which will maintain history, if that is something you're interested in, instead of the monthly snapshots.