git branch
git
쓰는 꼴
git branch [-a|-vv] [-d <name>]브랜치를 나열하고 만들고 지웁니다 — 지워도 원격에는 그대로 남아 서버에서 없애려면 git push origin --delete가 따로 필요합니다.
자주 쓰는 옵션
| 옵션 | 뜻 |
|---|---|
| -a | local and remote-tracking branches |
| -r | remote-tracking branches only |
| -vv | last commit and upstream of each branch |
| -d <name> | delete a branch that is already merged |
| -D <name> | delete it even if unmerged; those commits are left behind |
| -m <old> <new> | rename |
| --merged | branches already contained in the current one |
| --show-current | print the branch you are on |
예시
git branch -vvevery local branch with its upstream and last commit
git branch -d old-featureremoves a merged branch locally only
git push origin --delete old-featurethe separate step that removes it on the server
되돌리는 방법이 여럿이라 헷갈립니다 — 가리키는 곳을 옮기는 것과 새 커밋을 얹는 것은 다릅니다.
읽는 방법
- 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
- 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
- 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.
자주 묻는 것
Q. git branch은 무엇을 하나요?
브랜치를 나열하고 만들고 지웁니다 — 지워도 원격에는 그대로 남아 서버에서 없애려면 git push origin --delete가 따로 필요합니다.
Q. 어떻게 치나요?
git branch [-a|-vv] [-d <name>] — 대괄호는 생략할 수 있는 자리입니다.
Q. 옵션은 몇 개나 자주 쓰나요?
여기 정리한 것은 8개입니다. 전체 목록은 man git에 있습니다. 이 명령은 git 갈래입니다.
같이 보는 명령
man 페이지: man git-branch