로컬 Git 브랜치 이름 수정하는 법

LONGNEW·2020년 12월 27일
0

StackOverFlaw

목록 보기
5/16

https://stackoverflow.com/questions/6591213/how-do-i-rename-a-local-git-branch

Q. How do I rename a local Git branch?
Q. 로컬 Git 브랜치 이름을 수정하려면 어떻게 해야 하나요?
How can I rename a local branch which hasn't been pushed to a remote branch?
아직 리모트 브랜치에 push되지 않은 로컬 브랜치 이름을 바꾸려면 어떻게 해야 하나요?


If you want to rename a branch while pointed to any branch, do:
어떠한 브랜치를 가리키고 있는 상황에서, 브랜치의 이름을 변경하려 할 때는 아래와 같은 커맨드를

git branch -m <oldname> <newname>

If you want to rename the current branch, you can do:
현재의 브랜치 이름을 변경하려 할 때

git branch -m <newname>

A way to remember this is -m is for "move" (or mv), which is how you rename files.
'-m'옵션은 이름이 어떻게 변경되었다는 것을 의미한다.
Adding an alias could also help.
줄임말을 추가하는 것도 도움이 된다.
To do so, run the following:

git config --global alias.rename 'branch -m'

If you are on Windows or another case-insensitive filesystem, and there are only capitalization changes in the name, you need to use -M, otherwise, git will throw branch already exists error:
윈도우나 다른 시스템에서, 대`소문자 변경을 하려고 할 때는 -M 옵션을 쓰자. 근데 적절하지 않으면 브랜치는 존재합니다 라는 에러를 출력한다.

git branch -M <newname>

0개의 댓글