본문 바로가기

백앤드 개발

보초를 위한 Git 이용한 프로젝트 관리 방법

반응형

참조: http://nvie.com/posts/a-successful-git-branching-model/



용어 설명


remote: 말그대로 원격서버

commit: 업데이트라고 생각하면 될듯? 코드 제출이라고 해야하나

origin: remote 중에서도 메인이 되는 애

branch: 말그대로 가지. 코드의 흐름이다.

origin/master: 메인 서버의 마스터 브랜치

tag: 브랜치 내에서 버전 정보



Git 프로젝트 관리시


main 브랜치를 기준으로 (master 브랜치도 가능)


업데이트가 필요할시에 각 피처 및 버그 브랜치를 임시 생성하고 완료되면 merge를 하고 그 브랜치를 없애는 방식이 좋다.





생 시작시

git init 아니면 git clone https://github.com/USERNAME/REPOSITORY.git


origin remote 추가하기 

git remote add origin git@github.com:username/new_repo 


origin에 밀어 넣기

git push -u origin master 

.

.

.

.

.

.


main 브랜치 -> myfeature branch 생성 및 이동


git checkout -b myfeature main 



.

.

.

.


피쳐 개발 중

.

.

.

모든 변경사항 추가

git add -A

commit을 한다. 이렇게하면 로컬에서만 커밋을 한다.

git commit -a -m "개발 중 ㅋㅋㅋㅋ 빡치네"


origin(서버)로 업데이트한다

git push 아니면 git push origin main


.

.

.

.

개발 완료

.

.


main에 다시 머지 한다


main 브랜치로 이사

git checkout main | 다른 사람것 merge시 : git fetch, git branch -r


merge 시작

 git merge --no-ff myfeature


myfeature 브랜치 용도 파기

로컬: git branch -d myfeature,  리모트: git push origin --delete myfeature


로컬에 업데이트 된 정보를 origin(서버)로 밀어넣는다. origin이라는 remote에 master라는 브랜치에 밀어넣는거임

 git push origin main



아래 그림과 같은 느낌이다. develop = main




리모트 조회하기

 git remote -v

 리모트로 부터 데이터 가져오기

 git fetch [remote-name]

 현재

 git remote set-url https://github.com/USERNAME/REPOSITORY.git

 태그 추가

 git tag -a 1.2.1

 태그 조회

 git tag

 리모드 브랜치 조회

 git branch -r

 

 


반응형