본문 바로가기

리눅스

[GIT] 깃 브랜치(git branch) 생성, 삭제

반응형

git branch 생성, 삭제

로컬 branch 생성(Deployment environment)

git branch [<options>] (-c | -C) [<old-branch>] <new-branch>

git checkout -b "testing"

$ git checkout -b "testing"
Switched to a new branch 'testing'

$ git checkout -b "staging"
Switched to a new branch 'staging'

branch 확인(현재 branch)

git branch --list

git branch

$ git branch
--
  dev
  master
  testing
* staging
---

로컬 branch 이름 변경(dev -> development)

git branch [<options>] (-m | -M) [<old-branch>] <new-branch>

git branch -m dev development

로컬 branch 삭제

git branch [<options>] [-r] (-d | -D) <branch-name>

git branch -D dev

$ git branch -d dev
Deleted branch dev (was e178f0c).

$ git branch -D ggg
Deleted branch ggg (was f2b8f21).

branch 확인(현재 branch)

git branch

$ git branch
---
  development
  master
  production
* staging
  testing
(END)
---

원격 저장소에 branch 생성

git push origin staging

$ git push origin staging
Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for staging, visit:
remote:   http://gitlab.sangchul.kr/playground/merge_requests/new?merge_request%5Bsource_branch%5D=staging
remote:
To http://gitlab.sangchul.kr/playground.git
 * [new branch]      staging -> staging

원격 저장소에 branch 삭제

git push origin :dev

$ git push origin :dev
To http://gitlab.sangchul.kr/playground.git
 - [deleted]         dev

 

728x90
반응형