본문 바로가기

Tips/Git

[Git] 충돌 해결, Conflict solution

반응형

 

공동으로 작업하고 있는 origin에 연결된 브랜치(origin develop)에 충돌이 발생하는 경우

해결하는 방법을 작성했습니다.

1 ) git checkout feature/test

내가 작업하는 브랜치(feature/test)로 이동

2 ) git pull origin develop

공동으로 작업하고 있는 origin에 연결된 브랜치(origin develop)의 내용을 가져옴(pull)

3) 충돌 여부 확인

 3-1) 충돌이 발생한 경우 : 충돌한 파일을 수정

 3-2) 출돌이 발생하지 않은 경우 : 4번으로 진행

4) git add .

작업하고 있는 브랜치(feature/test)의 Untracked Files를 모두 한번에 stage(혹은 Index) 함

5) git status

On branch develop 
Your branch is up to date with 'origin/develop'.

nothing to commit, working tree clean

현재 저장소 내 파일들의 상태를 확인할 수 있음

현재 작업중인 브랜치 및 commit 내역을 확인할 수 있음

 

git add 가 되었으면 Stage Area(혹은 Index)에 포함된 내역을 확인할 수 있음

“Changes to be committed” 목록에 있는 파일은 Staged 상태를 의미함

6) git commit -m [설명]

작업중인 브런치(feature/test)에 Staged된 파일들을 commit 함

7) git log

commit c8ec6efd1c91b519a92172e4241e14335a4e0b87 (HEAD -> develop, origin/develop)
Merge: 36ee716 bbb5191
Author: chati
Date:   Tue Sep 29 16:44:09 2020 +0900

commit 이력을 확인할 수 있음

정상적으로 commit이 됐을 경우 아래와 같이 표시됨

 

“c8ec6efd1c91b519a92172e4241e14335a4e0b87” 값은 commit할 때 SHA-1 hash를 사용해 만들어진 40자 길이의 16진수 check sum data로, 

git 에서 사용하는 가장 기본적인 원자 데이터임

이후 변경한 내용이 문제가 생겼을 경우 위 값을 기준으로 다시 해당 시점으로 돌아올 수 있음

 


 Tip 

git config user.name / git config user.email

git을 commit할 때 사용할 이름과 메일 주소를 확인할 수 있음

 

git config --global user.name “OOO” / git config --global user.eamil “.com”

git을 commit할 때 사용할 이름과 메일 주소를 변경할 수 있음

 

 


[참고] http://gitready.com/beginner/2009/01/18/the-staging-area.html

 

git ready » the staging area

committed 18 Jan 2009 One of the most essential concepts to Git is that of the staging area. Its use can fundamentally change how you work, for the better! Let’s go over how exactly it works and what you’ll need to know to use it. With most other versi

gitready.com

 

반응형

'Tips > Git' 카테고리의 다른 글

[Git] 사용법  (0) 2020.06.13
[Git] Local Project에서 Git Repository랑 연동  (0) 2019.11.13

❥ CHATI Github