How to commit a Git repo to an empty repo SVN server?

后端 未结 2 706
谎友^
谎友^ 2020-12-23 15:35

I have setup an empty svn on a server and I have been working on locally making commits along the way. Now I wish to commit my repo to an svn server. For this I tried:

2条回答
  •  遥遥无期
    2020-12-23 15:55

    I needed something like this recently and the process is relatively straightforward.

    There's good tutorial by Brandon Dimcheff, "Commit a linear git history to subversion" (replaces old broken link), which these steps are based on.

    As of Git version 1.6.3 these are the steps:

    $ svnadmin create svn_repository
    $ svn mkdir -m "Initial setup" file:///full/path/to/svn_repository/trunk
    
    $ mkdir gitrepo && cd gitrepo
    $ git init
    $ echo 'Hello from Git' > file.txt
    $ git add file.txt
    $ git commit -m "Hello from Git"
    
    $ git svn init --trunk=trunk file:///full/path/to/svn_repository/
    $ git svn fetch
    
    $ git branch -a # Lists remotes/trunk
    
    $ git rebase --onto remotes/trunk --root master
    # => Applying: Hello from Git etc.
    
    $ git svn dcommit
    # => Committing to ... Committed r2 ... etc
    

    You can do a svn checkout of svn_repository now and see your Git repo.

提交回复
热议问题