상세 컨텐츠

본문 제목

Git Multi Remote 관리 방법

개발공부/개발공부

by Dal_pang 2026. 2. 28. 18:00

본문

실무에서 하나의 Git 프로젝트를 여러 원격 저장소(Remote Repository) 와 동시에 관리해야 하는 상황은 생각보다 자주 발생한다.

예를 들면:

  • GitHub + 사내 GitLab에 동시에 코드 미러링
  • 개인 포트폴리오용 GitHub + 회사 내부 저장소 분리
  • 오픈소스 upstream 저장소 + 개인 fork 저장소
  • 백업 또는 배포용 remote 분리

이 글에서는 Git multi remote 개념부터 실전 운영 방법까지 정리한다.


1. Git Remote 기본 개념

Git에서 remote 는 로컬 저장소와 연결된 원격 저장소의 별칭(alias) 이다.

기본적으로는 origin 하나만 존재한다.

git remote -v
origin https://github.com/user/project.git (fetch)  
origin https://github.com/user/project.git (push)

하지만 Git은 remote 개수에 제한이 없다.


2. Multi Remote가 필요한 상황

대표적인 케이스

상황설명
코드 미러링 GitHub ↔ GitLab 동시 관리
Fork 구조 upstream(원본) + origin(내 fork)
권한 분리 읽기 전용 remote / 쓰기 전용 remote
배포 분리 개발용 저장소 / 배포 자동화용 저장소

3. Remote 추가하기

기본 문법

git remote add <remote-name> <repository-url>

예시

git remote add origin https://github.com/user/project.git
git remote add gitlab https://gitlab.com/user/project.git

확인:

git remote -v
origin https://github.com/user/project.git (fetch)  
origin https://github.com/user/project.git (push)  
gitlab https://gitlab.com/user/project.git (fetch)  
gitlab https://gitlab.com/user/project.git (push)

4. Remote 이름 전략 (중요)

추천 네이밍 컨벤션

용도 Remote 이름
기본 저장소 origin
원본 오픈소스 upstream
GitLab gitlab
백업 backup
배포용 deploy

 

❗ origin은 내가 push하는 기준 저장소 로 유지하는 것을 추천


5. 특정 Remote로 push / pull 하기

Push

git push origin main  
git push gitlab main

Pull

git pull origin main  
git pull upstream main

6. Fork 구조에서의 Multi Remote (실무 필수)

구조 예시

origin → 내 fork

upstream → 원본 저장소

git remote add upstream https://github.com/original/project.git

확인:

git remote -v

upstream 최신 코드 가져오기

git rebase upstream/main
git checkout main
git merge upstream/main

또는 rebase:

git rebase upstream/main

7. 하나의 push로 여러 Remote에 동시에 반영하기

방법 1️⃣ push 시 명시적으로 여러 번

git push origin main  
git push gitlab main

방법 2️⃣ 하나의 remote에 여러 push URL 설정 (고급)

git remote set-url --add --push origin https://github.com/user/project.git
git remote set-url --add --push origin https://gitlab.com/user/project.git

확인:

git remote -v

이제 한 번만 실행해도:

git push origin main

두 저장소에 동시에 push

⚠️ 실무에서는 실수 방지를 위해 CI/CD 미러링 방식을 더 선호하는 경우도 많음


8. Remote URL 변경 / 삭제

URL 변경

git remote set-url origin https://new-url.git

Remote 삭제

git remote remove gitlab

9. 실무 운영 팁 (중요)

✅ 원칙 1: Push 대상은 명확히

  • origin만 직접 push
  • 다른 remote는 자동화 또는 명시적 push

✅ 원칙 2: upstream은 절대 push 금지

git remote set-url --push upstream DISABLE

✅ 원칙 3: CI/CD 미러링 적극 활용

  • GitLab/GitHub의 Repository Mirroring
  • 사람 손으로 여러 remote push 최소화

10. 추천 운영 시나리오

개인 + 회사 병행 프로젝트

origin → 개인 GitHub (주 저장소)
gitlab → 회사 GitLab (미러)
upstream → 오픈소스 원본

배포 자동화 분리

origin → 개발 저장소
deploy → ArgoCD / CI 배포 전용


마무리

Git의 multi remote 기능은:

  • 단순하지만
  • 실무에서 생산성을 크게 올려주고
  • 협업·백업·배포 전략을 유연하게 만든다

핵심은 개수보다 “역할 분리”와 “명확한 규칙”이다.

728x90

관련글 더보기