简体   繁体   中英

convert local svn repo to git

I have what should be a svn repo. in a local folder in my computer. I don't know if it is possible but I would like to convert it so it uses git only. I no longer have access to the svn server and all there inside the .svn folder is

all-wcprops
entries
format
prop-base
props
text-base
tmp

I have tried doing svn log but it starts asking for credentials. I have also tried verifying that it is an svn repo by doing something like svnadmin verify /folder but all it says is svnadmin: Can't open file 'format': No such file or directory . All I need is the commit history.

If this is the repository (not a local workspace), use git svn clone to slurp it into a newly created git repository. Check the result 5 ways through Sunday, ditch the SVN to a nice, cosy CD/DVD for safekeeping.

Note that git svn clone can take a very long time, as it sequentially asks SVN to recreate each sigle revision there ever was, and then integrates that as a commit. SVN is inefficient when digging up old stuff, and the handling by git svn isn't precisely stellar either. For a not-so-large, remote SVN repo it can well take a day or two. I had to restart such several times, as the connection broke. I don't remember if the right incantation was git svn clone again or git svn rebase , or something else (yes, it is scary seeing an empty clone repository, but the downloaded stuff is there).

If you don't mind losing history (as I mentioned in my comment, if you don't have access to the central server, you don't have access to the history), you can init a git repo in the same folder, add a .gitignore file with all the files/folders you usually ignore in SVN in addition to the line .svn/ , to ignore the .svn folders, then add/commit everything.

With command line git, this would look like:

cd path/to/repo
git init
touch .gitignore
#EDIT THE .gitignore FILE HERE
git add .
git commit -m "Initial commit"

If you want to clean out the .svn folders later, you can either use the link in werd's answer or clone the repo to another folder .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM