Git SVN notes
Newbie notes on using Git with a remote SVN repo.
Git SVN notes
Setting up
Clone repo using (-s) standard trunk, branches, tags:
git svn clone -s https://svn.koansys.com/cjp/buildout buildout cd buildout
'clone' is same as 'init' followed by 'fetch'.
Working
Do work:
edit edit edit git add file git add .
Commit locally:
git commit -m "message"
Push back to svn:
git svn dcommit
Get latest from svn:
git svn fetch git svn rebase
Show branches, first the local copies:
$ git branch * master
You can also show all possible branches. The remotes (so far) don't have local copies; when local checkouts are created, they'll show up under the simple svn branch command as above:
$ git branch -a * master remotes/0.1-robrien remotes/0.1-robrien@141 remotes/0.1-robrien@95 remotes/0.2 remotes/0.2-robrien remotes/cjp.buildout-0.1 remotes/cjp.buildout-0.1@141 remotes/trunk remotes/trunk@141 remotes/trunk@74
Show the origin (of the current branch?):
$ git svn info Path: . URL: https://svn.koansys.com/cjp/buildout/trunk Repository Root: https://svn.koansys.com/cjp
Switching branches
You can switch to another branch like the following but notice that it tells you that you need to check it out, and that explains why you'll see "(no branch)":
$ git checkout remotes/0.1-robrien Note: moving to 'remotes/0.1-robrien' which isn't a local branch If you want to create a new branch from this checkout, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new_branch_name> HEAD is now at 71a5481... renaming for typing convenience $ git svn info Path: . URL: https://svn.koansys.com/cjp/buildout/branches/0.1-robrien Repository Root: https://svn.koansys.com/cjp $ git branch * (no branch) master
Never mess with remote branches. Instead create a local branch to track the remote. When you check it out, you're switched to it:
$ Git checkout --track -b remotes/0.2-robrien Branch remotes/0.2-robrien set up to track local branch master. Switched to a new branch 'remotes/0.2-robrien' (buildout)chris@Mackeral:buildout$ branches bash: branches: command not found $ git branch master * remotes/0.2-robrien
And you can switch back:
$ git checkout master Switched to branch 'master' (buildout)chris@Mackeral:buildout$ bit branch bash: bit: command not found $ git branch * master remotes/0.2-robrien
Other tools
gitk
Builds as part of git, gitx seems much nicer.
gitx for OX X
Graphical history browser and commit gui: http://gitx.frim.nl/
diffmerge
Also available for Linux, windows: http://www.sourcegear.com/diffmerge/downloads.html
Ensure SVN is on Proper Remote
I don't understand why yet but a "git svn clone ..." will create a "master" based on the remote "trunk" but other times on some "tag/tagname". Perhaps it defaults "master" to whatever was updated in SVN last, I don't know.
Use "git svn info" to see what it points at, and if it's not what you expect, you can do something like:
git checkout -b trunk remotes/trunk git branch -D master
Merging
NEED MORE DETAILS, ACCURACY HERE
I've modified base.cfg, can't "git svn rebase" (update-index --refresh: command returned error: 1). If I git commit, then git svn dcommit it says I've got merge conflict, out of date, try updating
git mergetool --tool diffmerge git svn rebase --continue Find lost TODOS
git log -p -S'TODO'

