7 ๋ถ„ ์†Œ์š”



branch scenario

1. branch ์‚ฌ์šฉ๋ฒ•

๋ธŒ๋žœ์น˜๋ฅผ ์กฐ์ž‘ํ•  ๋•Œ๋Š” ๋ฐ˜๋“œ์‹œ master ๋ธŒ๋žœ์น˜์˜ ์ตœ์†Œ 1๊ฐœ์˜ ์ปค๋ฐ‹์€ ์žˆ์–ด์•ผํ•œ๋‹ค!!!



์‹ค์Šต ์ค€๋น„

  • ๋”ฐ๋ผํ•ด ๋ณธ๋‹ค.
# git ์ดˆ๊ธฐํ™” ๋ฐ commit ๋‚จ๊ฒจ๋†“๊ธฐ

$ git init
$ touch a.txt 
# a.txt text 1์ด๋ผ๋Š” ๊ธ€์„ ์ž‘์„ฑํ•œ๋‹ค.

$ git add .
$ git commit -m'text2'
[master 67f01f6] text2
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 b.txt
# 3๊ฐœ์˜ ์ปค๋ฐ‹์„ ๋” ๋‚จ๊ธด๋‹ค.
$ git log --oneline
b9aaaf5 (HEAD -> master) test3
67f01f6 text2
acf00f0 Initial commit





ex. ์ด์ œ ์šฐ๋ฆฌ๋Š” ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ์„ ๊ฐœ๋ฐœํ•ด๋ณธ๋‹ค๊ณ  ๊ฐ€์ •

$ git branch feature/login # ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ๋งŒ
$ git branch
  feature/login
* master



master ๋ธŒ๋žœ์น˜์—์„œ ๋งˆ์ง€๋ง‰ ์ค„ ์ถ”๊ฐ€

text 1
text 2
text 3
master์—์„œ ์ž‘์„ฑํ•œ text 4 # ์ถ”๊ฐ€

# add, commit
$ touch d.txt # master์—์„œ d.txt๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค.
$ git add .
$ git commit -m'master text 4'
[master 121a503] master text 4
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 d.txt

 
 # log
$ git log --oneline
121a503 (HEAD -> master) master text 4
b9aaaf5 (feature/login) test3
67f01f6 text2
acf00f0 Initial commit



๋ธŒ๋žœ์น˜ ์ด๋™์„ ํ•˜๊ณ  a.txt๋ฅผ ํ™•์ธํ•ด๋ณด์ž

$ git checkout feature/login 
Switched to branch 'feature/login'

# master text 4๊ฐ€ ์‚ฌ๋ผ์ง

# log ํ™•์ธ
$ git log --oneline
b9aaaf5 (HEAD -> feature/login) test3
67f01f6 text2
acf00f0 Initial commit
# ํ˜„์žฌ ๋ธŒ๋žœ์น˜๋Š” feature/login

text 1
text 2
text 3
login text 4 # ์ถ”๊ฐ€

๋ธŒ๋žœ์น˜๋ฅผ ๋‹ค๋ฃฐ ๋•Œ๋Š” ํ˜„์žฌ ๋‚ด๊ฐ€ โ€˜์–ด๋–คโ€™ ๋ธŒ๋žœ์น˜์— ์žˆ๋Š”์ง€๋ฅผ ๋ฐ˜๋“œ์‹œ ์•Œ์•„์•ผ ํ•จ!!!

# login.txt

login text 4 # ์ถ”๊ฐ€
$ touch login.txt

$ git status
On branch feature/login
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        login.txt # WD + commit ์ด๋ ฅ ์—†์Œ(git์ด ์ง€๊ธˆ๊นŒ์ง€ ํ•œ๋ฒˆ๋„ ์ถ”์ ํ•œ์  ์—†์Œ)

nothing added to commit but untracked files present (use "git add" to track)


# add, commit
$ git add .
$ git commit -m'login text4'
[feature/login f6dda89] login text4
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 login.txt

# ํ˜„์žฌ ๋ธŒ๋žœ์น˜๋Š”? feature/login
$ git log --oneline
f6dda89 (HEAD -> feature/login) login text4
b9aaaf5 test3
67f01f6 text2
acf00f0 Initial commit


# ๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜์˜ ๊ทธ๋ž˜ํ”„๊นŒ์ง€ ๋ณด๋Š” ๋ฐฉ๋ฒ•
$ git log --all --graph --oneline
* f6dda89 (HEAD -> feature/login) login text4
| * 121a503 (master) master text 4
|/
* b9aaaf5 test3
* 67f01f6 text2
* acf00f0 Initial commit



2. branch merge scenario

  • ๋“œ๋ผ์ด๋ธŒ์— git-merge ํด๋” ์ƒ์„ฑ ํ›„ ํ•ด๋‹น ํด๋”์—์„œ vs code๋ฅผ ์—ด์ž! image

  • ctrl + ๋ฐฑํ‹ฑ(1์™ผ์ชฝ์— ์žˆ๋Š”)์„ ๋ˆ„๋ฅธ ํ›„ Git Bash ํด๋ฆญ ํ›„ ์ž‘์—…

image


$ git init
Initialized empty Git repository in F:/git-merge/.git/

$ touch test.txt

  • test.txt์— master test 1์ด๋ผ๊ณ  ์ฑ„์›Œ๋„ฃ๊ธฐ (์ €์žฅ ๊ผญ!!) image
$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        test.txt

nothing added to commit but untracked files present (use "git add" to track) 

$ git add .
$ git commit -m'master test 1'
[master (root-commit) 9fe5f83] master test 1
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt
 
# log
$ git log
commit 9fe5f839afe5de4e366dc981f62f9692cce859ee (HEAD -> master)
Author: ingu627 <rjsdudans@naver.com>
Date:   Sun Nov 21 19:41:06 2021 +0900

    master test 1



3๊ฐ€์ง€ ๋ณ‘ํ•ฉ ์ƒํ™ฉ

1. fast-forward

image-20210706133955957

  • ์ฃผ์˜ ์‚ฌํ•ญ! ๋ฐ˜๋“œ์‹œ master ๋ธŒ๋žœ์น˜์—๋Š” 1๊ฐœ ์ด์ƒ์˜ ์ปค๋ฐ‹์ด ์กด์žฌํ•ด์•ผ ํ•จ!!!

โ€œ๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜๊ฐ€ ์ƒ์„ฑ๋œ ์ดํ›„์— master ๋ธŒ๋žœ์น˜์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์—†๋Š” ์ƒํ™ฉ => ๋‹จ์ˆœํ•˜๊ฒŒ master ๋ธŒ๋žœ์น˜์˜ ํฌ์ธํ„ฐ๋ฅผ ์ตœ์‹  commit์œผ๋กœ ์ด๋™ ์‹œํ‚จ๋‹ค.โ€

master ๋ธŒ๋žœ์น˜์—์„œ feature/login ๋ธŒ๋žœ์น˜๋ฅผ ๋ณ‘ํ•ฉ(merge) ํ•  ๋•Œ feature/login ๋ธŒ๋žœ์น˜๊ฐ€ master ๋ธŒ๋žœ์น˜ ์ดํ›„์˜ commit์„ ๊ฐ€๋ฆฌํ‚ค๊ณ  ์žˆ๋‹ค๋ฉด master ๋ธŒ๋žœ์น˜๋Š” feature/login ๋ธŒ๋žœ์น˜๊ฐ€ ๊ฐ€๋ฆฌํ‚ค๊ณ  ์žˆ๋Š” ์ตœ์‹  commit์œผ๋กœ ํฌ์ธํ„ฐ(HEAD)๋ฅผ ์ด๋™ ์‹œํ‚ค๋ฉด ๋œ๋‹ค.

1. feature/login ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ ํ›„ ์ด๋™

$ git checkout -b feature/login
Switched to a new branch 'feature/login'

2. ํŠน์ •ํ•œ ์ž‘์—…์„ ์™„๋ฃŒํ•˜๊ณ  commit ์ง„ํ–‰

$ touch login.txt
$ git add .
$ git commit -m'login test 1'
[feature/login 6302c25] login test 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 login.txt

# log
$ git log --oneline
# master ๋ธŒ๋žœ์น˜์—์„œ feature/login ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ -> feature/login ๋ธŒ๋žœ์น˜์—์„œ ์ƒˆ๋กœ์šด commit ์ƒ์„ฑ
6302c25 (HEAD -> feature/login) login test 1
9fe5f83 (master) master test 1

image

3. master ๋ธŒ๋žœ์น˜๋กœ ์ด๋™

  • ๋ธŒ๋žœ์น˜๋ฅผ ์ด๋™ํ•˜๋Š” ์ˆœ๊ฐ„ login.txt ํŒŒ์ผ์ด ์‚ฌ๋ผ์ง„๋‹ค.
  • ์™œ๋ƒํ•˜๋ฉด login.txt ํŒŒ์ผ์€ master ๋ธŒ๋žœ์น˜๊ฐ€ ์•„๋‹ˆ๋ผ feature/login ๋ธŒ๋žœ์น˜์—์„œ commit(๋ฒ„์ „)์„ ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์ž„
 $ git checkout master
 Switched to branch 'master'

image

4. master ๋ธŒ๋žœ์น˜์— feature/login ๋ธŒ๋žœ์น˜์—์„œ ์ž‘์—…ํ•œ ๊ฒฐ๊ณผ๋ฌผ ๋ณ‘ํ•ฉ

  • ๋ณ‘ํ•ฉ ์ดํ›„์— login.txt ํŒŒ์ผ์ด ์ƒ๊น€
    • ๋ณ‘ํ•ฉํ•˜๊ณ ์ž ํ•˜๋Š” ๋ธŒ๋žœ์น˜๋กœ ์ด๋™ํ•œ ํ›„ ์ž‘์—…
$ git merge feature/login
Updating 9fe5f83..6302c25
Fast-forward
login.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 login.txt

image

5. ๋กœ๊ทธ ํ™•์ธ

  • HEAD -> master๊ฐ€ ์œ„๋กœ ์˜ฌ๋ผ์™”์Œ!
# ๋ณ‘ํ•ฉ ์ „
$ git log --oneline
# master ๋ธŒ๋žœ์น˜์—์„œ feature/login ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ -> feature/login ๋ธŒ๋žœ์น˜์—์„œ ์ƒˆ๋กœ์šด commit ์ƒ์„ฑ
6302c25 (HEAD -> feature/login) login test 1
9fe5f83 (master) master test 1

# ๋ณ‘ํ•ฉ ํ›„ 
$ git log --oneline
6302c25 (HEAD -> master, feature/login) login test 1
9fe5f83 master test 1

6. ๋ธŒ๋žœ์น˜ ์‚ญ์ œ

$ git branch -d feature/login
Deleted branch feature/login (was 6302c25).

# ํ™•์ธ
$ git branch
* master

$ git log --oneline
6302c25 (HEAD -> master) login test 1
9fe5f83 master test 1



2. Merge commit -> conflict x

image-20210706135659337

๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜(feature/signup)๊ฐ€ ์ƒ์„ฑ๋œ ์ดํ›„์— master ๋ธŒ๋žœ์น˜์— ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ๊ณ  feature/signup ๋ธŒ๋žœ์น˜์—๋„ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ -> ์ด๋•Œ ์ถฉ๋Œ ์ƒํ™ฉ์ด ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ

  • ๋‹ค๋ฅธ ํŒŒ์ผ์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ž‘์„ฑ(์ˆ˜์ •) commitํ•œ ๊ฒฝ์šฐ

  • Merge commit ์ด ๋ฐœ์ƒํ•จ
    • ์ด commit ๋‚ด์—ญ์€ ์šฐ๋ฆฌ๊ฐ€ ์ง์ ‘ ์ž‘์„ฑํ•œ commit์ด ์•„๋‹Œ git์ด ์ž๋™์œผ๋กœ ์ž‘์„ฑํ•ด์ค€ commit message
  • ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š” ์ด์œ ๋Š” ๋‹ค๋ฅธ ํŒŒ์ผ (๊ฐ™์€ ํŒŒ์ผ์ด๋ผ๋„ ๋‹ค๋ฅธ ๋ผ์ธ์„ ์ˆ˜์ •ํ•œ ๊ฒฝ์šฐ ํฌํ•จ)์ด๊ธฐ ๋•Œ๋ฌธ์— ๋‹จ์ˆœํ•˜๊ฒŒ ํ•ฉ์น˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ!

1. signup ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ & ์ด๋™

  • git checkout -b ๋ธŒ๋žœ์น˜์ด๋ฆ„ : ์ด๋ฆ„๋ช…์œผ๋กœ ์ƒ์„ฑํ•˜๊ณ  ๊ทธ ๋ธŒ๋žœ์น˜๋กœ ์ด๋™
$ git checkout -b feature/signup
Switched to a new branch 'feature/signup'

2. ํŠน์ •ํ•œ ์ž‘์—…์„ ์ง„ํ–‰ํ•˜๊ณ  commit

$ touch signup.txt

# add, commit
$ git add .
$ git commit -m'signup test 1'
[feature/signup 586d298] signup test 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 signup.txt
   
# log
$ git log --oneline
586d298 (HEAD -> feature/signup) signup test 1  # feature/signup ๋ธŒ๋žœ์น˜์˜ ์ตœ์‹  ์ปค๋ฐ‹ + ํ˜„์žฌ ๋‚ด๊ฐ€ ์œ„์น˜ํ•œ ๋ธŒ๋žœ์น˜
6302c25 (master) login test 1 # master ๋ธŒ๋žœ์น˜์˜ ์ตœ์‹  ์ปค๋ฐ‹
9fe5f83 master test 1

image

3. master๋กœ ์ด๋™

  • ์ด๋™ํ•˜๋Š” ์ˆœ๊ฐ„ signup.txt ํŒŒ์ผ์ด ์‚ฌ๋ผ์ง
  • signup ๋ธŒ๋žœ์น˜์—์„œ ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  commit ํ–ˆ๊ธฐ ๋•Œ๋ฌธ!
$ git checkout master
Switched to branch 'master'

$ git log --oneline
6302c25 (HEAD -> master) login test 1
9fe5f83 master test 1

image

4. master ๋ธŒ๋žœ์น˜์—์„œ ์ถ”๊ฐ€ ์ž‘์—…์„ ์ง„ํ–‰ํ•œ ๋‹ค์Œ commit

$ touch master.txt

# add, commit
$ git add .
$ git commit -m'master test 1'
[master 2c9f3c0] master test 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 master.txt
   
# log 
$ git log --oneline
2c9f3c0 (HEAD -> master) master test 1
6302c25 login test 1
9fe5f83 master test 1

# ๋ธŒ๋žœ์น˜ ํฌํ•จ ๋ชจ๋“  log๋ฅผ ํ™•์ธํ•  ๋•Œ 
$ git log --all --oneline
2c9f3c0 (HEAD -> master) master test 1
586d298 (feature/signup) signup test 1
6302c25 login test 1
9fe5f83 master test 1

5. master ๋ธŒ๋žœ์น˜์— ๋ณ‘ํ•ฉ

  • merge๋ฅผ ์ง„ํ–‰ํ•˜๊ณ ๋‚˜์„œ ํ™•์ธํ•ด๋ณด๋‹ˆ signup.txt๊ฐ€ ์ƒ๊ธฐ๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Œ
$ git merge feature/signup
Merge made by the 'recursive' strategy.
 signup.txt | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 signup.txt

# log
$ git log --oneline
6e469f3 (HEAD -> master) Merge branch 'feature/signup' # ์šฐ๋ฆฌ๊ฐ€ ์ง์ ‘ ์ž…๋ ฅํ•œ commit x -> Merge commit
2c9f3c0 master test 1
586d298 (feature/signup) signup test 1
6302c25 login test 1
9fe5f83 master test 1

6. log

  • graph๋กœ ๋ณด๊ณ ์ž ํ•  ๋•Œ
$ git log --all --graph --oneline
*   6e469f3 (HEAD -> master) Merge branch 'feature/signup'
|\
| * 586d298 (feature/signup) signup test 1
* | 2c9f3c0 master test 1
|/
* 6302c25 login test 1
* 9fe5f83 master test 1

7. branch ์‚ญ์ œ

$ git branch -d feature/signup
Deleted branch feature/signup (was 586d298).

$ git log --all --graph --oneline
*   6e469f3 (HEAD -> master) Merge branch 'feature/signup'
|\
| * 586d298 signup test 1
* | 2c9f3c0 master test 1
|/
* 6302c25 login test 1
* 9fe5f83 master test 1



3. Merge commit -> conflict o

๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜(feature/signup)๊ฐ€ ์ƒ์„ฑ๋œ ์ดํ›„์— master ๋ธŒ๋žœ์น˜์— ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ๊ณ  feature/signup ๋ธŒ๋žœ์น˜์—๋„ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ -> ์ด๋•Œ ์ถฉ๋Œ ์ƒํ™ฉ์ด ๋ฐœ์ƒํ•˜๋Š” ๊ฒฝ์šฐ

  • ๊ฐ™์€ ํŒŒ์ผ์˜ ๊ฐ™์€ ๋ถ€๋ถ„์„ ์ž‘์„ฑ(์ˆ˜์ •)ํ•˜์—ฌ commitํ•œ ๊ฒฝ์šฐ

  • Merge commit ์ด ๋ฐœ์ƒํ•จ
    • ์ด commit ๋‚ด์—ญ์€ ์šฐ๋ฆฌ๊ฐ€ ์ง์ ‘ ์ž‘์„ฑํ•œ commit์ด ์•„๋‹Œ git์ด ์ž๋™์œผ๋กœ ์ž‘์„ฑํ•ด์ค€ commit message
  • ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•˜๋Š” ์ด์œ ๋Š” ๊ฐ™์€ ํŒŒ์ผ์˜ ๊ฐ™์€ ๋ถ€๋ถ„์„ ์ˆ˜์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์–ด๋–ค ๋ฒ„์ „์œผ๋กœ ๋งŒ๋“ค์ง€ git์€ ์•Œ ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ!
  • ๊ทธ๋ž˜์„œ ์ง์ ‘ ์šฐ๋ฆฌ๊ฐ€(==์‚ฌ๋žŒ์ด) ์ˆ˜์ •ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

1. hotfix ๋ธŒ๋žœ์น˜ ์ƒ์„ฑ ํ›„ ์ด๋™

$ git checkout -b hotfix
Switched to a new branch 'hotfix'

2. ํŠน์ • ์ž‘์—… ์™„๋ฃŒ ํ›„ & commit ์ง„ํ–‰

# hotfix branch์˜ test.txt
master test 1
์ด๊ฑด hotfix ๋ธŒ๋žœ์น˜์—์„œ # ์ถ”๊ฐ€
์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

image

$ git add .
$ git commit -m'hotfix test 1'
[hotfix 03ba33b] hotfix test 1
 1 file changed, 3 insertions(+), 1 deletion(-)
   
$ git log --oneline
03ba33b (HEAD -> hotfix) hotfix test 1
6e469f3 (master) Merge branch 'feature/signup'
2c9f3c0 master test 1
586d298 signup test 1
6302c25 login test 1
9fe5f83 master test 1

3. master๋กœ ์ด๋™

$ git checkout master
Switched to branch 'master'

4. ํŠน์ • ์ž‘์—… ํ›„ commit

  • hotfix ๋ธŒ๋žœ์น˜์—์„œ ์ž‘์—…ํ•œ ๋ถ€๋ถ„๊ณผ ๋™์ผํ•œ ๋ถ€๋ถ„์„ ์ˆ˜์ •
# master branch์˜ test.txt
master test 1
์ด๊ฑด master ๋ธŒ๋žœ์น˜์—์„œ # ์ถ”๊ฐ€
์ˆ˜์ •ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.

image

$ git add .
$ git commit -m'master test 1'
[master b74a431] master test 1
 1 file changed, 3 insertions(+), 1 deletion(-)

# log
$ git log --oneline
b74a431 (HEAD -> master) master test 1
6e469f3 Merge branch 'feature/signup'
2c9f3c0 master test 1
586d298 signup test 1
6302c25 login test 1
9fe5f83 master test 1

5. Merge

$ git merge hotfix 
Auto-merging test.txt
CONFLICT (content): Merge conflict in test.txt # ์ถฉ๋Œ.. -> merge ํ•˜๋Š” ๊ณผ์ •์—์„œ ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•จ -> test.txt

# ์ž๋™์œผ๋กœ ๋ณ‘ํ•ฉํ•˜๋Š” ๊ฒƒ ์‹คํŒจ!! -> ์ถฉ๋Œ์„ ํ•ด๊ฒฐํ•˜๊ณ  ๋‚œ ๋‹ค์Œ์— ๊ทธ ๊ฒฐ๊ณผ๋ฅผ commit ํ•˜์…ˆ
Automatic merge failed; fix conflicts and then commit the result.

image

  • ๊ฐ™์€ ๋ถ€๋ถ„(๋ผ์ธ)์„ ๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜์—์„œ ๊ฐ๊ฐ ์ˆ˜์ •ํ•˜๊ณ  commit ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ณ‘ํ•ฉํ•˜๋Š” ๊ณผ์ •์—์„œ git์€ ์–ด๋–ค ๋ถ€๋ถ„์„ ํ•ฉ์ณ์•ผ ํ•˜๋Š”์ง€ ์•Œ ์ˆ˜ ์—†์Œ -> ๊ทธ๋ž˜์„œ ์šฐ๋ฆฌ๊ฐ€ ์ง์ ‘ ํ•ฉ์น˜๊ณ  ๋‚˜์„œ merge commit์„ ๋ฐœ์ƒ ์‹œ์ผœ์•ผ ํ•œ๋‹ค.

     master test 1
     <<<<<<< HEAD
     ์ด๊ฑด master ๋ธŒ๋žœ์น˜์—์„œ 
     ์ˆ˜์ •ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.
     =======
     ์ด๊ฑด hotfix ๋ธŒ๋žœ์น˜์—์„œ
     ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.
     >>>>>>> hotfix
    

image

# ์ˆ˜์ •
master test 1
์ด๊ฑด master ๋ธŒ๋žœ์น˜์—์„œ 
์ˆ˜์ •ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.
์ด๊ฑด hotfix ๋ธŒ๋žœ์น˜์—์„œ
์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.
# master | MERGING -> Merge commit์„ ๋‚จ๊ฒจ์•ผ ํ•จ

image

$ git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   test.txt # both modified

no changes added to commit (use "git add" and/or "git commit -a")

# add๋กœ ์˜ฌ๋ฆฌ๊ณ  commit์œผ๋กœ Merge commit์„ ์ง์ ‘ ๋‚จ๊ธด๋‹ค.
$ git add .
$ git commit -m "์ถฉ๋Œ ํ•ด๊ฒฐ!!!"
[master 03c4743] ์ถฉ๋Œ ํ•ด๊ฒฐ!!!

6. log ํ™•์ธ

  • ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ์—๋Š” 6e469f3 (HEAD -> master) Merge branch 'feature/signup' ์ด๋Ÿฌํ•œ commit์„ git์ด ์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ฃผ์ง€๋งŒ ์ถฉ๋Œ์„ ์ง์ ‘ ํ•ด๊ฒฐํ•˜๋Š” ๊ฒฝ์šฐ ์šฐ๋ฆฌ๊ฐ€ ์ถฉ๋Œ์„ ํ•ด๊ฒฐํ–ˆ๋‹ค๋Š” ์˜๋ฏธ์˜ ์ปค๋ฐ‹์„ ์ง์ ‘ ๋‚จ๊ธธ ์ˆ˜ ์žˆ๋‹ค.
$ git log --oneline
03c4743 (HEAD -> master) ์ถฉ๋Œ ํ•ด๊ฒฐ!!!
b74a431 master test 1
03ba33b (hotfix) hotfix test 1
6e469f3 Merge branch 'feature/signup'
2c9f3c0 master test 1
586d298 signup test 1
6302c25 login test 1
9fe5f83 master test 1

7. branch ์‚ญ์ œ

$ git branch -d hotfix
Deleted branch hotfix (was 03ba33b).

# log
$ git log --all --oneline --graph
*   03c4743 (HEAD -> master) ์ถฉ๋Œ ํ•ด๊ฒฐ!!!
|\
| * 03ba33b hotfix test 1
* | b74a431 master test 1
|/
*   6e469f3 Merge branch 'feature/signup'
|\
| * 586d298 signup test 1
* | 2c9f3c0 master test 1
|/
* 6302c25 login test 1
* 9fe5f83 master test 1



References

ํƒœ๊ทธ:

์นดํ…Œ๊ณ ๋ฆฌ:

์—…๋ฐ์ดํŠธ:

๋Œ“๊ธ€๋‚จ๊ธฐ๊ธฐ