sitelink1 | https://velog.io/@nakta/Git-Repository-%...8%EA%B8%B0 |
---|---|
sitelink2 | https://blog.naver.com/hsylove87/221981679524 |
sitelink3 |
현재 운영중인 저장소의 모든 정보를 로컬로 다운받은후 새로운 저장소로 옮기는 과정이다
remote의 저장소 주소는 .git 폴더가 위치한 경로이다
ex> https://github.com/<user.name에적혀있는이름>/<저장소명>.git
* 저장소 데이터를 임시로 저장할 로컬 경로에서 다음의 명령어들을 수행한다
* Git Bash 실행
$ git clone --mirror {현재 운영중인 저장소 주소}
$ cd <저장소명>
$ git push --mirror {새로 이사갈 저장소 주소}
위와 같이 임시 로컬저장소에 소스를 모두 다운로드후 새로운 원격저장소에 업로드 하는 경우엔 clone 과 push 명령줄로만 가능하다
하지만 로컬저장소가 임시가 아닌 작업저장소인 경우엔 로컬저장소의 정보에서도 새로운 원격저장소를 바라보게 할 필요가 있다
이런 경우엔 다음과 같은 방식으로 데이터 백업/복원 후 remote set-url 명령을 통해 원격저장소 정보를 로컬저장소에 업뎃 해줘야 한다
현재 commit 이력과 repo 내용 전부 new repo url 로 변경
예시)
http://origin.com/repo.git >> http://new.com/repo.git
1. 현재 remote url 확인
git remote -v
>
origin http://origin.com/repo.git (fetch)
origin http://origin.com/repo.git (push)
2. 현재 repo clone
git clone --mirror http://origin.com/repo.git
3. 새로운 repo url setting
git remote set-url --push origin http://new.com/repo.git
4. push
git push --mirror
5. 현재 remote url 확인
git remote -v
>
origin http://origin.com/repo.git (fetch)
origin http://new.com/repo.git (push)
5-1. fetch 가 이전 url을 보고 있기때문에 바꾸고 싶으면 아래와 같이 실행
git remote remove origin >> remote 되어있는 git을 삭제
git remote -v >> 현재 remote 연결 없는 것을 확인
git remote add origin http://new.com/repo.git >> 다시 remote 연결 git remote -v
>
origin http://new.com/repo.git (fetch)
origin http://new.com/repo.git (push)