기존 repository를 새로운 repository로 옮기기
git clone --mirror { git repository 주소 }
// 만약 특정 브랜치만 가져온다면
git clone -b { 브랜치명 } --single-branch --mirror { git repository 주소 }
// clone을 정상적으로 완료했다면 repository명.git 파일이 생성되어 있을 것이다
// 아래의 명령어를 통해 이름을 .git으로 변경
mv repository명.git .git
// .git으로 변경한 디렉토리에서 아래 명령을 실행
git remote set-url origin { 새로운 repository 주소 }
// .git으로 변경한 디렉토리에서 아래 명령을 실행
// 아래의 명령을 실행하게 되면 새로운 repository로 push 된다.
git push --mirror
여러 계정을 사용할 때는 SSH-Key를 만들어서 등록해 사용하면 된다.
$ ssh-keygen -t rsa -C "userA@my_email.com" -f "id_rsa_userA"
# 이메일은 깃헙에 등록된 이메일 & 파일 이름을 지정해준다.
# 키 등록
$ ssh-add id_rsa_userA
# ssh config 파일을 설정한다.(~/.ssh/config 경로에 생성한다.)
# Host 부분에 자신이 사용할 이름을 지정한다.
# 깃헙계정 main
# -------------------
Host github.com-main
HostName github.com
IdentityFile ~/.ssh/id_rsa_main
User git
# 깃헙계정 sub
# -------------------
Host github.com-sub
HostName github.com
IdentityFile ~/.ssh/id_rsa_sub
User git
# remote origin url을 설정할 때 config에서 설정한 host를 이용한다.
GitHub 여러 계정을 한 컴터에서 사용하기 - 1ilsang