Git-svn

From Git SCM Wiki
(Difference between revisions)
Jump to: navigation, search
Line 88: Line 88:
 
* tcoffee description, including tagging, committing to a branch: http://code.google.com/p/tcoffee/wiki/SvnUsingGitClient  
 
* tcoffee description, including tagging, committing to a branch: http://code.google.com/p/tcoffee/wiki/SvnUsingGitClient  
 
*  [http://utsl.gen.nz/talks/git-svn/intro.html An introduction to git-svn for Subversion/SVK users and deserters] by Sam Vilain describes how to import from and work with Subversion repositories and SVK mirrors. Also describes why would one want to choose Git over Subversion.
 
*  [http://utsl.gen.nz/talks/git-svn/intro.html An introduction to git-svn for Subversion/SVK users and deserters] by Sam Vilain describes how to import from and work with Subversion repositories and SVK mirrors. Also describes why would one want to choose Git over Subversion.
 +
* [http://michael-prokop.at/blog/2007/12/03/git-svn-in-30-minutes/ git(-svn) in 30 minutes] on [http://michael-prokop.at/blog mikas blog], not only about git-svn.
  
 
[[Category:GitDocumentation]] [[Category:git-svn documentation]]
 
[[Category:GitDocumentation]] [[Category:git-svn documentation]]

Revision as of 23:48, 25 December 2012

This tutorial collects information for users of git as subversion client, using git-svn. Please consider reading GitSvnCrashCourse, and the git-svn cheatsheet. As Git is distributed, commits (aka change sets) are referenced by hashes instead of svn's serial version numbers. Git tracks contents, not files or directories. Consider to use a real svn client to rename directories, as git-svn produces a lot of renames in svn, instead of one like the original.

Contents


checkout / clone, log, configure basics

git svn clone -r 400:HEAD https://mysvnsrv.org/rep/trunk folder # choose a recent commit
git log -5
git status
git svn info
git config --list

Create a .gitignore file on the toplevel to replicate svn's ignore properties.

echo "folder/or/file/to/ignore" > .gitignore

Make sure to remove directories from the svn tree if there are no files left in it. This is important for a directory move to have no left-overs:

git config --global svn.rmdir=true

commit

commit to local Git

Git automatically tracks contents and therefor automatically detects all changes done with file browsers, programming tools etc.

git diff
git add --all
git diff --cached
git commit -m "whatebber"

commit to remote SVN

To see what is going to be committed one can choose the following options.

gitk git-svn..
gitk
git log remotes/git-svn.. --oneline
git svn dcommit --dry-run

To really commit

git svn dcommit

undo changes

Undo (backout, revert) changes and commits is done with standard git commands.

Things already committed to svn can be reverted:

git revert <hash>
git svn dcommit

Things in the working tree can be reset (reverted) to what is checked in:

git reset --hard

Also, single files can be reset to a previous version. one caret means one version back:

git checkout HEAD^ -- singlefile
git commit --amend

basic workflow, check out, fix, check in to svn

git svn clone -r 400:HEAD https://mysvnsrv.org/rep
... hack, hack, hack ...
git add .
git commit -m "qick fix"
git dcommit


workflow with quickly setting away your main work and do a quick fix

git svn clone -r 400:HEAD https://mysvnsrv.org/rep
git checkout -b bugfix-id-123
... hack, hack, hack ...
git stash "main work, save it for the moment"
git stash list
... hack on quick fix ...
git commit -m "qick fix"
git dcommit
git stash pop
... continue hack, hack, hack ...

workflow with local fix/feature branch

git svn clone https://mysvnsrv.org/rep
git checkout -b bugfix-id-123
<hack, hack, hack>
git add --all
git commit -m "fixed issue 123"
git checkout master
git svn rebase
git merge bugfix-id-123
git svn dcommit

Some links

Personal tools