[Git] remote repository 설정

윤동환·2023년 1월 26일
0

Git

목록 보기
1/4
post-thumbnail

원격 저장소 설정하기

로컬 repository에서 초기화

# git 
git init

원격 저장소 추가

git remote add

이 명령어는 두가지 인수를 사용합니다.

  • 원격 이름
  • 원격 URL
git remote add [원격 이름] [원격 저장소 URL]
git remote add origin https://github.com/USER/REPO.git

원격 원본이 존재한다면 이러한 에러를 만날 수 있습니다.

git remote add origin https://github.com/octocat/Spoon-Knife.git
fatal: remote origin already exists.

해결 방법
1. 다른 원격 이름 사용
2. 기존 원격 저장소 이름 변경
3. 기존 원격 저장소 삭제

원격 저장소 URL 변경

git remote set-url

이 명령어는 두가지 인수를 사용합니다.

  • 기존에 존재하는 원격 이름
  • 새로운 원격 저장소 URL
git remote set-url [원격 이름] [원격 저장소 URL]
git remote set-url origin 
# HTTPS 사용시
https://github.com/USERNAME/REPOSITORY.git
# SSH 사용시
git@github.com:USERNAME/REPOSITORY.git

remote 이름 변경하기

remote 이름과 url을 확인한다

$ git remote -v
# View existing remotes
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)

확인한 이름을 기반으로 바꿀 이름을 입력한다.

git remote rename

이 명령어는 두가지 인수를 사용합니다.

  • 기존 remote name
  • 바꿀 remote name
$ git remote rename origin destination
# Change remote name from 'origin' to 'destination'

$ git remote -v
# Verify remote's new name
> destination  https://github.com/OWNER/REPOSITORY.git (fetch)
> destination  https://github.com/OWNER/REPOSITORY.git (push)

참고 사이트 링크

profile
모르면 공부하고 알게되면 공유하는 개발자

0개의 댓글