Using GIT with SVN
Sometimes it might be useful to use Git to work on some existing SVN repositories. This allows you to work with local branches and lets you work offline.
Checkout the SVN rep
git-svn clone -s http://example.com/my_subversion_repo local_dir
Use the -s flag if the SVN rep has the standard trunk/branches/tags layout
cd local_dir git-svn show-ignore > .gitignore
Tell Git about the ignored files. Slow operation, later on add .gitignore to the rep
Local modifications using Git
Edit the files. When you’re done:
git add . git rm file_not_needed_anymore git commit
Send the new stuff to the SVN rep:
git-svn rebase
This will do a SVN update and apply the changeset to our working copy
git-svn dcommit
And there we go.
Local modification using a Git branch
git branch new_branch_name git checkout new_branch_name
(you can combine the two operations with git checkout -b new_branch_name
)
Now you can edit the files. When you’re done:
git add . git rm file_not_needed_anymore git commit
Now it’s time to merge back the branch:
git checkout master git merge new_branch_name
If you want to combine all the branch’s commit into a single merge:
git merge --squash new_branch_name
Now it’s time to send the new stuff to the SVN rep:
git-svn rebase
This will do a SVN update and apply the changeset to our working copy
git-svn dcommit
And there we go.
Undoing changes
If you didn’t add changes to the changeset yet:
git checkout filename
If you did you have to reset the changeset first:
git reset HEAD filename
Sources
http://www.viget.com/extend/effectively-using-git-with-subversion/