This is my own use of git svn. No one in Google seems to have this mix listed out for a Subversion project with a proper trunk/branch/tag setup, so I decided to post what I’ve got.
Getting a repository:
git svn clone --tags <tags subfolder> --trunk <trunk subfolder> --branches <branches subfolder>
Updating SVN-tracking remote branches in git:
git svn fetch
Working on trunk:
git checkout master; git svn rebase
Working on a branch for the first time:
git checkout -b local/<branchname> <remote branchname>
Working on a branch:
git checkout local/<branchname>; git svn rebase
After committing, merging, or any other action that changed the local git repository, push to SVN:
git svn dcommit
Making a new branch in SVN:
git checkout master; git svn branch <branchname> -m "Branching for <reason or bug#>"
Making a new tag in SVN:
git checkout <tagged commit>; git svn tag -m "Tagging for <reason or release>"
Deleting a branch in SVN:
svn rm svn://host/path/to/branch; git branch -D local/<branchname>; git branch -D -r <branchname>; rm -rf .git/svn/refs/remotes/<branchname>
Deleting a tag in SVN:
svn rm svn://host/path/to/tag; git branch -D -r tags/<branchname>; rm -rf .git/svn/refs/remotes/tags/<branchname>
Merging a branch (properly):
git checkout <merge-to branch>; git merge --squash <merge-from branch>; git commit; git svn dcommit # --squash is key
Comments
Hi there!
I am also a “Git Rebel” at my work. Care to explain why “squash” is key? I’ve had numerous problems getting merging between two repositories to work.
Thanks.
If you made 10 commits to a git branch, then merged it, git will understand the metadata and only represent the 10 commits once. Subversion, however, will see the 10 commits in one branch as separate from the 10 merged commits, resulting in 20 commits total. This is an absolute mess.
Since the metadata is lost no matter what you do, you might as well make it clean. The –squash option means you get all 10 commits merged into trunk (or wherever) as one commit labeled accordingly.
If some one desires to be updated with hottest
technologies therefore he must be go to see this site and be up to date daily.