상세 컨텐츠

본문 제목

[Git] commit, push, merge

Operating System (OS) & Network & VCS/Git

by 찌니씨 2022. 10. 7. 10:59

본문

git

commit & push
$ git commit -am "커밋 메시지 내용" //Staged 상태로 commit 생성
$ git status //파일 상태 확인
$ git log //commit 내역 확인
$ git add //파일 추적, staged상태

$ git push - u origin master //commit을 원격저장소로부터 업데이트를 받은 후 push 원격 저장소에 업로드
$ git remote add origin <원격 서버 주소> //원격으로 push

 

commit error

hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

위의 massage와 같이 충돌이 발생하면

메시지의 파일을 찾아 충돌 해결 후

$ git add file_name
$ git commit

 


 merge branch
$ git merge branch_name
$ git merge branch_name --edit // 병합 후 바로 vi 편집기가 나오면서 커밋 메시지 수정 가능
$ git merge branch_name --no-edit // 커밋 메시지 수정없이 바로 병합

 

 


 GitFlow에 따른 feature branch 관리와 명령어 (기본)

'feature branch' (feature / ing_job)를 'develop branch'에서분기

  (혹은 새로운 branch생성)

 

Local

 

$ git checkout -b feature/ing_job develop //create new branch (feature/ing_job) and checkout

 

Remote Repository

 

$ git remote add feature/ing_job GitAddress //create new branch
$ git push origin newbranch //git push

 

새로운 기능에 대한 작업 수행 
 'feature branch'에서 모든 작업이 끝나면
 'develop branch' 로 이동한다.

 

$ git checkout develop

 

 

 'develop branch'에 feature / ing_job branch 내용을 병합(merge)한다.

 

$ git merge --no-ff feature/ing_job //‘feature’ 브랜치에 존재하는 커밋 이력을 모두 합쳐서 하나의 새로운 커밋 객체를 만들어 'develop branch' 에 merge 한다
$ git branch -d feature/ing_job // -d 옵션: feature/ing_job 에 해당하는 branch를 삭제한다.
$ git push origin develop // 'develop branch' 를 원격 중앙 저장소에 올린다.

'Operating System (OS) & Network & VCS > Git' 카테고리의 다른 글

[Git] Commit tamplate file  (0) 2022.10.12
[Git] Cherry-pick  (0) 2022.10.11
[Git] Merge 되돌리기  (0) 2022.10.11
[Git] Flow 수정, 초기화  (0) 2022.10.07
[Git] Branch 전략 (Git Flow)  (0) 2022.10.07

관련글 더보기

댓글 영역