Git Subtree Merge and git-svn
Issue: Git submodules do not play nicely with git-svn; git subtree merging is a more appropriate strategy for my specific use case.
Resolution: This is my recipe (borrowed heavily from the formal git documentation).
git remote add -f Bproject /path/to/B
git merge -s ours --no-commit Bproject/master
git read-tree --prefix=dir-B/ -u Bproject/master
git commit -m "Task - JIRA-001 - Merge B project as our subdirectory"
git checkout master
git merge TRY-MERGE master -m "Task - JIRA-001 - Merging subtrees into project."
git-svn dcommit
You may update your local copy from the remote at any time with:
Reference: http://kernel.org/pub/software/scm/git/docs/v1.7.0/howto/using-merge-subtree.html
Commit a linear git history to subversion
Issue: I was recently asked to integrate my local development (which I had done under git management) into our central Subversion server. How to do this while preserving my commit history?
Resolution: After a lot of reading (and an upgrade to git-1.7.0) I found the following recipe to work for me.
git-svn init svn://repo.domain.local/Project/trunk/sub/directory
git-svn fetch
git checkout -b svnrebase git-svn
git-svn rebase
git rebase --root --onto svnrebase master
git-svn dcommit
Recursively delete .svn directories
Abstract
This is a simple example of a unix command, which recursively deletes subversion .svn folders. Subversion is a well-spread open-source revision control application. Every copy of source code received from subversion repository has .svn folders, which store metadata. However, if you want to use or distribute source code for end-user consumption, these folders are not necessary. A simple svn export [repository] is suitable.
Compatible
- Linux, FreeBSD, Mac OS X, Cygwin...
- Nearly any unix-compatible system with rm and find
We use find command to find all .svn folders beginning from current directory.
$ find . -type d -name .svn
./.svn ./sourceA/.svn ./sourceB/.svn ./sourceB/module/.svn ./sourceC/.svn
It is possible to pass these directories directly to rm command, using grave accent quotes (key to left of '1')
$ rm -rf `find . -type d -name .svn`
So, this will remove every .svn folder beginning from current directory.
Source code: bash script
#!/bin/sh echo "recursively removing .svn folders from" pwd rm -rf `find . -type d -name .svn`
You may save this script to /usr/bin/csvn (or other binary folder included in path) and use later to get 'clean' project source without typing lengthy commands.
For example,
$ svn checkout svn://server.com/svn/project A project/index.php A project/sourceA/a.php A project/sourceA/a1.php A project/sourceA/a2.php A project/sourceB/b.php A project/sourceB/module/lib.php A project/sourceC/c.php Checked out revision 15. $ cd project $ csvn
Warning
Always check you current working directory before calling 'csvn'.