본문 바로가기

git

git branch 생성, 삭제

branch 조회

$ git branch -r  : remote 브랜치 조회

$ git branch -a : local + remote 브랜치 조회

 

branch 생성 - local to remote

feature-01 branch 생성

$ git checkout -b feature-01

 

remote branch에 생성한 branch push

$ git push origin feature-01

 

local과 remote branch 연동

$ git branch --set-upstream-to origin/feature-01

 

branch 생성 - remote to local

$ git checkout -t origin/브랜치명   < remote 브랜치를 가져오면서 local 같은 이름의 브랜치 생성>

 

branch 삭제

$ git branch -d branch_name : merge 브랜치만 삭제됨

$ git branch -D branch_name : merge 안된 브랜치도 삭제됨

 

.gitignore 파일 적용

$ git rm -r --cached /node_modules

$ git rm -r --cached .gitignore

$ git add .
$ git commit -m "Apply .gitignore"

 

서버에서 new repository 만들기

디렉토리 생성 해당 디렉토리로 이동하여 아래 명령 실행.

git init --bare --shared

 

Local commit view

$ git log origin/1_cctv..HEAD

$ git diff origin/1_cctv..HEAD

 

Modify commit message

$ git commit --amend