git remote
git
쓰는 꼴
git remote -v | git remote add <name> <url>원격 저장소의 이름과 주소를 다룹니다 — 적어 두는 일뿐이라 add나 set-url을 해도 fetch·push를 하기 전에는 아무것도 오가지 않습니다.
자주 쓰는 옵션
| 옵션 | 뜻 |
|---|---|
| -v | list the remotes with their URLs |
| add <name> <url> | register another repository |
| set-url <name> <url> | point an existing remote somewhere else |
| rename <old> <new> | rename a remote |
| remove <name> | forget a remote |
| show <name> | branches it has and how they are tracked |
| prune <name> | drop tracking refs for branches deleted there |
예시
git remote -vshows the fetch and push URL of every remote
git remote add upstream https://github.com/orig/repo.gitadds the original repo alongside your fork
git remote set-url origin git@github.com:me/repo.gitswitches origin from HTTPS to ssh
되돌리는 방법이 여럿이라 헷갈립니다 — 가리키는 곳을 옮기는 것과 새 커밋을 얹는 것은 다릅니다.
읽는 방법
- 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
- 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
- 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.
자주 묻는 것
Q. git remote은 무엇을 하나요?
원격 저장소의 이름과 주소를 다룹니다 — 적어 두는 일뿐이라 add나 set-url을 해도 fetch·push를 하기 전에는 아무것도 오가지 않습니다.
Q. 어떻게 치나요?
git remote -v | git remote add <name> <url> — 대괄호는 생략할 수 있는 자리입니다.
Q. 옵션은 몇 개나 자주 쓰나요?
여기 정리한 것은 7개입니다. 전체 목록은 man git에 있습니다. 이 명령은 git 갈래입니다.
같이 보는 명령
man 페이지: man git-remote