[Git] From SVN to Git

2024. 6. 26. 23:05Tool/Git

 
SVN에서 Git으로 전환하는 업무가 있었고, 여러 방법 중 제가 다루려고 하는 방법을 적습니다.
 
- (    ) 는 임의의 변수 값입니다.
- git remote repository는 github 또는 gitlab에 생성되어 있다고 가정하고 시작합니다.
 
1. 환경 설정
git config --global user.name '(username)' 
git config --global user.email '(email)'
git config --global init.defaultBranch main           // master가 아닌 main을 default로 고정
git config --list                      // git config 목록 확인 가능합니다.
 
2. git local repository dir 생성
mkdir (local repo dir)
cd (local repo dir)
git init
 
3. git remote repository 연결
git remote add origin (remote repo url)
 
4. Git 과 SVN 연동
1)
git svn init (svn repo url)         // git svn init --trunk=trunk (svn repo url) 처럼 변경 가능합니다.
git svn fetch
또는
2)
git svn clone (svn repo url)
 
5. staging, commit, push
// git pull origin main
git rm -r --cached . 
git add .                          // .gitignore 적용
git commit -m 'initial commit'
// git push --set-upstream origin main
git push

6. Etc
git status : 파일들의 수정, 삭제 등 상태 확인
git log : git commit 기록 확인
git reflog : branch 등 확인 가능

 

'Tool > Git' 카테고리의 다른 글

[Git] VS code에서 Git Bash 사용하기  (0) 2024.05.13
[Git] 명령어 (수정중)  (0) 2024.02.03
[GitHub] Repository: private to public  (0) 2023.09.28
[GitHub] 프로필 생성  (0) 2023.09.15