| 55 | |
| 56 | == Pushing from a DVCS to SVN |
| 57 | |
| 58 | If the changes were staged in a Git or Hg repository, some additional steps are needed to commit the changes to Subversion. The steps will be described for a Git repository, but will be similar for an Hg repository. |
| 59 | |
| 60 | You should first interactively rebase (`git rebase -i`) your changes to get them in a form that is appropriate for committing to the Subversion repository. In doing so, consider how you'd like the changes to be represented in the repository history, taking into account that we frequently interrogate the repository history to discover the cause of regressions or understand the purpose and intent of code. For example, logically related changesets may be squashed if they were staged as multiple changesets to ease the process of codereview. However, unrelated changes and refactorings should be pushed as separate changesets, so they don't obfuscate other changesets. |
| 61 | |
| 62 | Next, reword your log messages in a form that is appropriate for committing to the Subversion repository, prefixing each log message with the target version (e.g. `1.0.10dev:`), and referencing the appropriate ticket(s). See the [/log log] for examples. |
| 63 | |
| 64 | Once you've interactively rebased your Git branch and prepared your log messages, the process to push changes to Subversion is: |
| 65 | * Checkout an svn working copy of the branch you'll be committing to |
| 66 | * Rebase your staging branch against the HEAD of the branch you'll be committing to |
| 67 | * Copy the svn metadata directory (`.svn`) of the working copy into the root of your git repository |
| 68 | * Step through checkouts of your repository changesets and push each of them into Subversion |
| 69 | |
| 70 | Here are the same steps described in command line form: |
| 71 | {{{#!sh |
| 72 | $ svn checkout <target-branch> trac-svn-wc |
| 73 | $ cp -r trac-svn-wc/.svn trac-git-repos/ |
| 74 | $ cd trac-git-repos |
| 75 | $ git status -sb |
| 76 | ## tXYZ |
| 77 | $ git checkout tXYZ~3 |
| 78 | $ git log --format="%B" > commit.txt |
| 79 | $ svn add ...; svn del ... |
| 80 | $ svn ci -F commit.txt |
| 81 | $ git checkout tXYZ~2 |
| 82 | ... |
| 83 | $ git checkout tXYZ~1 |
| 84 | ... |
| 85 | $ git checkout tXYZ |
| 86 | ... |
| 87 | }}} |