예제용 데이터
SVN 저장소 주소 : https://svn.example.com
Git 저장소 주소 : https://git.exmaple.com
Git 저장소 사용자의 그룹(회사) 도메인 : hellworld.com
SVN 저장소에 기여한 사용자 목록 추출
svn log -q https://svn.example.com | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors.txt
Git 저장소의 형식으로 사용자 목록 변경
perl -pi -e 's/>/\@hellworld.com>/g' ./authors.txt
SVN history를 Git history로 이관
git svn init https://svn.example.com --trunk=trunk --branches=banches --tags=tags --prefix=svn/
SVN tag를 Git tag로 변경
git for-each-ref refs/remotes/svn/tags | cut -d / -f 4- | grep -v @ | while read tagname; do IFS='/' read -ra realname <<< "$tagname"; git tag ${realname[1]} "svn/$tagname"; git branch -r -d "svn/$tagname"; done
SVN branch를 Git branch로 변경
git for-each-ref refs/remotes/svn | cut -d / -f 3- | grep -v @ | while read branchname; do IFS='/' read -ra realname <<< "$branchname"; git branch ${realname[1]} "$branchname"; done
master branch 존재하므로 trunk branch 삭제 (사소하지만 꼭 해주자)
git checkout master
git branch -D trunk
authors.txt 파일 삭제
rm authors.txt
SVN ignore 파일(trunk기준)을 Git ignore 파일로 변경 후 모든 Git 브랜치에 적용
git svn show-ignore -i svn/trunk > .gitignore
git add .gitignore
git commit -m 'Add Git ignore file'
git branch | sed 's/^..//' | while read branchname; do git checkout ${branchname}; git cherry-pick master; done
LFS migration 필요할 경우 수행(필요없다면 SKIP)
git lfs migrate import --include="*.[dD][oO][tT], *.[rR][tT][fF], *.[dD][oO][cC], *.[dD][oO][cC][xX], *.[pP][dD][fF], *.[xX][lL][sS], *.[xX][lL][sS][xX], *.[xX][lL][sS][mM], *.[pP][pP][tT], *.[pP][pP][tT][xX], *.[iI][pP][cC][hH], *.[sS][dD][fF], *.[sS][uU][oO], *.[dD][bB], *.[tT][xX], *.[dD][lL][lL], *.[eE][xX][eE], *.[lL][iI][bB], *.[jJ][pP][gG], *.[jJ][pP][eE][gG], *.[bB][mM][pP], *.[pP][nN][gG], *.[iI][cC][oO], *.[sS][dD][bB], *.[gG][iI][fF], *.[mM][sS][iI], *.[dD][sS][dD][pP], *.[dD][bB][sS], *.[oO][cC][xX], *.[dD][wW][gG], *.[eE][mM][fF], *.[iI][lL][kK], *.[tT][gG][aA], *.[aA][vV][iI], *.[wW][mM][vV], *.[wW][aA][vV], *.[mM][oO][vV], *.[mM][pP]3, *.[mM][pP]4, *.[oO][gG][vV], *.[xX][lL][lL], *.[sS][wW][fF], *.[dD][rR][vV], *.[pP][sS], *.[pP][sS][dD], *.7[zZ], *.[cC][aA][bB], *.[eE][aA][rR], *.[gG][zZ], *.[jJ][aA][rR], *.[rR][aA][rR], *.[tT][aA][rR], *.[tT][gG][zZ], *.[wW][aA][rR], *.[zZ][iI][pP], *.[pP][yY][dD], *.[pP][yY][lL], *.[pP][yY][cC], *.[pP][yY][oO], *.[pP], *.[tT][tT][fF], *.[sS][hH][xX], *.[fF][nN][tT], *.[oO][tT][fF]" --everything
git reflog expire --expire=now --all; git gc --prune=now --aggressive
git lfs install
Git 원격 저장소에 업데이트
git remote add origin https://git.exmaple.com
git push origin --tags
git push origin --all