Importing an svn branch into git

I am new to git, and have a subversion repository that I want to be able to import into a git repository occasionally (for deployment). So I want to perform most of the updates using svn but wanted to see what's the best way to push it to git (just the default/master branch).

-------------Problems Reply------------

I know you only want to import the master/trunk branch of your svn repository, but I would like to mention svn2git in order to import your svn into a git repository.

It is better than git svn clone because if you have this code in svn:

trunk
...
branches
1.x
2.x
tags
1.0.0
1.0.1
1.0.2
1.1.0
2.0.0

git-svn will go through the commit history to build a new git repo.
It will import all branches and tags as remote svn branches, whereas what you really want is git-native local branches and git tag objects.
So after importing this project, you would get:

$ git branch
* master
$ git branch -a
* master
1.x
2.x
tags/1.0.0
tags/1.0.1
tags/1.0.2
tags/1.1.0
tags/2.0.0
trunk
$ git tag -l
[ empty ]

After svn2git is done with your project, you'll get this instead:

$ git branch
* master
1.x
2.x
$ git tag -l
1.0.0
1.0.1
1.0.2
1.1.0
2.0.0

Finally, it makes sure the HEAD of master is the same as the current trunk of the svn repo.

Why not just work in git on your workstation too? That would be the most straightforward.

  • git svn clone will grab your SVN repository and import the revisions into a new git repo.
  • If you need to push to a remote git repository for deployment, then git remote add will add it for you.
  • If you need to push back to the SVN repository then git svn dcommit

in a nutshell:

mkdir my_blog_tmp
cd my_blog_tmp
git-svn init http://code.yoursite.net/my_blog/trunk/ --no-metadata
git config svn.authorsfile ~/Desktop/users.txt
git-svn fetch

and congrats for joining us gits! Here is a great cheat sheet for (ex)svn users.

Category:svn Views:2 Time:2009-02-05
Tags: svn git

Related post

  • How can I track multiple svn branches in git 2009-01-19

    There are so many ways to skin a cat, can anyone improve on this? --------------Solutions------------- That's a great article, but what really helped me was to understand the config for git svn. Assuming your SVN is setup like: $SVN_ROOT/project/trun

  • How to switch svn branches using git-svn? 2009-04-08

    Duplicate How do I make git-svn use a particular svn branch as the remote repository? I am using git-svn to track development by someone else on svn. I'm trying to figure out how to use gti-svn to switch from one svn branch to another. All the exampl

  • Delete a svn-Branch via git? 2009-12-03

    I'am using git as scm of choice but have to use a svn-repo. I can create a svn-remote-branch like this: git svn branch the_branch But how can i delete the remote branch? --------------Solutions------------- Currently, it is not possible to delete an

  • How do I access svn branches using git-svn with a non-standard svn repo layout? 2010-09-09

    The standard repo layout in svn is as follows. /trunk /branches featureX featureY /tags 1.0 2.0 The repository I'm working with is a much flatter structure. trunk featureX featureY Essentially, trunk is at the same level as the other branches. I can'

  • create a new svn branch with git-svn 2010-03-29

    While working with git-svn, and a 'typical' svn repo /trunk, /branches/..., /tags/... How do I push a local branch to a new branch inside of /branches ? --------------Solutions------------- Say we have a skeleton Subversion repository with empty trun

  • Problem cloning a single SVN Branch via git svn 2010-08-20

    I have tried the following command on my SVN Repository to clone only a single branch via git. git svn clone http://svn.supose.org/supose/branches/B_0.7.1 but got the the following error message: Initialized empty Git repository in /Users/km/workspac

  • Trouble importing all perforce branches into git repo 2011-05-19

    I'm trying to import a project from my company's Perforce depot into a git repository. I've been successful getting a single branch into a single git repo, but what I'd like to do is to pull in the entire project plus all branches, but I can't get it

  • Best way to import a svn repo to git that has trunk, tags, branches and releases 2009-11-13

    I run a project on sourceforge called mqmanager.NET that I inherited from the original author. Long story short I want to migrate this, and the rest of, my sourceforge projects to github. The problem here is that the typical import process assumes yo

  • Can you specify which svn branches with git svn? 2009-01-15

    I think my question is somewhat similar to CaptainPicard's but dissimilar enough that I feel compelled to ask so here goes. I have an old SVN repository with around 7500 revisions and part of those 7500 revisions are some pretty large .fla files. And

  • How to integrate svn branches into git branches with git-svn? 2011-03-02

    i have not much svn experience but i am used to work with git. I have the following svn repository structure and revisions. https://server/svn/solution/trunk/solution.sln @r100 https://server/svn/solution/trunk/project1/project1.csproj @r150 https://

  • How can I find what SVN branch my git branch will dcommit to? 2012-01-19

    How can I check what branch "svn dcommit" from my currently checked out branch is going to push to? --------------Solutions------------- git svn info will include the URL of the Subversion repo your git branch tracks. $ git svn info Path: . URL: svn+

  • git svn imported repository using svn branches 2010-08-24

    I've cloned a replicated svn repository (svnsync to local file system). All the branches etc. are now available in git. Now i would like to start working on svn branches git checkout remotes/B_XYZ and doing some commits via git. Now i want to change

  • How do I make git-svn use a particular svn branch as the remote repository? 2008-10-10

    A word of warning: I'm a n00b to git in general. My team uses feature branches in svn, and I'd like to use git-svn to track my work on a particular feature branch. I've been (roughly) following Andy Delcambre's post to set up my local git repo, but t

  • How to make an existing git branch track a remote SVN branch? 2010-07-22

    Similar to this question, how can I make an existing Git branch track a remote SVN branch? I often find that I start work in a local branch that I then need to push to an SVN server. Is this possible? --------------Solutions------------- The idea rem

  • Importing only specific files from a svn repository to git 2011-01-26

    I'm trying to import a few files from SVN to a new git repository. For Example, I have the following in SVN: files/file1 files/file2 files/file3 files/image1 files/image2 I want to import only the files/image* files. Is this possible? --------------S

  • Import/commit to svn branch from a different codebase 2010-04-30

    I am trying to migrate to svn from a not-so-famous version control system (lets call it nsfvc). svn trunk was created some time ago from nsfvc's trunk. There is an active branch in nsfvc that I have to import to svn branch. The diff between nsfvc's t

  • No longer track branches with git-svn 2011-01-25

    I have cloned a svn branch using git-svn and am tracking all folders and branches. I would like to drop everything and only track web/trunk/* (for rebase, dcommit, etc.) Is there any way to do this without reinitializing the repository? -------------

  • Create an SVN branch from an existing Git branch 2011-03-11

    I have cloned an existing SVN project via git svn clone with no problem so far, but in the mean time I have created a branch in Git only (not in SVN) and now i would like to synchronize this branch back to an SVN branch (not the trunk). I have create

  • Branching with Git and SVN 2012-02-02

    I cloned an SVN repository down and I've been working on master - checking things in locally - but I haven't yet pushed to SVN. Now, I've decided I want to push my local changes "on master" to a new SVN branch (not to the main trunk). What is the bes

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.074 (s). 11 q(s)