๐๋ธ๋์น ๋ณ ๋ณ๋์ ํ์ผ ์์ or ์ถ๊ฐ ๐ ์ถฉ๋X
๐๊ฐ์ ํ์ผ์ด์ง๋ง ๋ค๋ฅธ ํํธ๋ฅผ ์์ ๐ ์ถฉ๋X
๐ฅ ๊ฐ์ ํ์ผ / ๊ฐ์ ๋ถ๋ถ์ ์์ ํ ๊ฒฝ์ฐ ์ถฉ๋์ด ๋๋ค ๐ฅ
๐ main
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main)
$ dir
f1.txt f2.txt f3.txt s1.txt
๐ test
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (test)
$ dir
f1.txt f2.txt f3.txt s1.txt s2.txt
๐ํ์ฌ s2.txt๊ฐ test์๋ง ์๋๊ฒ์ ๋นผ๋ฉด branch๋ณ ํ์ผ์ ๋ชจ๋ ๊ฐ์!
๐ main
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main)
$ vim s1.txt
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main)
$ cat s1.txt
function a(){
}
function b(merge){
}
function c(){
}
๐ test
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main)
$ git checkout test
Switched to branch 'test'
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (test)
$ vim s1.txt
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (test)
$ cat s1.txt
function a(){
}
function b(conflict){
}
๐ฅ main์ s1.txt์ test์ s1.txt๋ฅผ ๊ฐ์ ํํธ์ ๋ค๋ฅธ ๋ด์ฉ์ ์ ์.
โก function b(){ }: ํ๋ผ๋ฏธํฐ ๋ด๋ ๋ถ๋ถ์ ๋ค๋ฅด๊ฒ ์ ์
๐ฅ merge - ์ถฉ๋๋ฐ์!
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main)
$ git merge test
Auto-merging s1.txt
CONFLICT (content): Merge conflict in s1.txt
Automatic merge failed; fix conflicts and then commit the result.
๐ ์ถฉ๋์ด ๋ฐ์ํ ํ์ผ ์ด๋ฆ๊ณผ merge ์คํจ๋ฅผ ์๋ ค์ค
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main|MERGING)
$ git status
On branch main
Your branch is ahead of 'origin/main' by 5 commits.
(use "git push" to publish your local commits)
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Changes to be committed:
new file: s2.txt
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: s1.txt
๐ ํ์ฌ merge๋ ์คํจํจ, ๊ทธ๋ฌ๋ ๋ณํฉ์ ์ํฌ branch์ ์์น์์ ๋ฌธ์ ๊ฐ ์๊ธด s1.txt๋ฅผ ์์ ํ๋ผ๋ ์๋ฌ ๋ฉ์ธ์ง๋ฅผ ํ์ธ
โ s1.txt ๋ฅผ ์ด์ด๋ณด๋ฉด git์์ ์ปค๋ฐ์ง์ , ์ถฉ๋์ง์ , ๊ฒน์น๋ ๋ถ๋ถ์ ํ์ํด์ค
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main|MERGING)
$ cat s1.txt
function a(){
}
<<<<<<< HEAD ๐ master์์ ์ปค๋ฐ๋ Head๋ function a()๋ถํฐ ๋ผ๋ ๋ป
function b(merge){
}
function c(){
======= ๐ ์ด ๋ถ๋ถ์์ ๊ฒน์น๋ค๋ ๋ป
function b(conflict){
>>>>>>> test ๐ test ๋ธ๋์น์์ function b๋ ์ด๋ ๊ฒ ์ฐ์ฌ ์๋ค๋ ๋ป
}
โก conflict๊ฐ ์ผ์ด๋๋ ๋ถ๋ถ์ ์ฌ์ฉ์๊ฐ ์์ ํ๋ผ๊ณ git์์ ๊ถํ์ ๋๊ฒจ์ฃผ๋ ๊ฒ.
โ ์ฌ์ฉ์๋ ์ถฉ๋์ง์ ์ ํ์ธ ํ ์์ ํ๊ณ ๋ค์ ์ ์ฅํ๋ฉด ๋๋ค.
function a() {
}
function b() {
}
function c(merge,conflict) { ๐ ์์
}
๐ฅ์์ ํ ์ปค๋ฐ
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main|MERGING)
$ git status
On branch main
Your branch is ahead of 'origin/main' by 5 commits.
(use "git push" to publish your local commits)
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Changes to be committed:
new file: s2.txt
Unmerged paths: ๐ merge ์คํจํ ๋ถ๋ถ์ ์๋ ค์ค
(use "git add <file>..." to mark resolution)
both modified: s1.txt ๐ ์์ ์๋ฃํ s1.txt๋ฅผ ๋ณด์ฌ์ค
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main|MERGING)
$ git add s1.txt ๐ s1.txt๋ฅผ add
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main|MERGING)
$ git status ๐ status์์ ๋ฌธ์ X
On branch main
Your branch is ahead of 'origin/main' by 5 commits.
(use "git push" to publish your local commits)
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
modified: s1.txt
new file: s2.txt
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main|MERGING)
$ git commit -m "fix the conflict" ๐์ปค๋ฐโผโผ
[main f0bb4a7] fix the conflict
๐๋ก๊ทธ ํ์ธ
ssnhh@DESKTOP-9APISNT MINGW64 ~/git/forGit (main)
$ git log --decorate --graph
* commit f0bb4a72a9799720dae86aeb9144ab22e6b56278 (HEAD -> main)
|\ Merge: 8ab1175 d277107
| | Author: ssnhhyejin <ssnhhyejin@gmail.com>
| | Date: Mon Feb 27 14:59:03 2023 +0900
| |
| | fix the conflict
| |
| * commit d277107d28e7509df31e5651deb2db1d06282c67 (test)
| | Author: ssnhhyejin <ssnhhyejin@gmail.com>
| | Date: Fri Feb 24 19:29:04 2023 +0900
| |
| | modified-s1-funcb
| |
| * commit 039f491c26d6993230826492c27a7bf491835d50
| | Author: ssnhhyejin <ssnhhyejin@gmail.com>
| | Date: Fri Feb 24 19:21:38 2023 +0900
| |
| | stash finish
| |
| * commit e83248ce3e9fe5997a9c608f82b213d2b072d7e0
| | Author: ssnhhyejin <ssnhhyejin@gmail.com>
| | Date: Fri Feb 24 15:30:59 2023 +0900
| |
| | stash3
| |
| * commit cd27f5c0691a2ffb5a1e0e44f2abfd6e8c2273fd
| | Author: ssnhhyejin <ssnhhyejin@gmail.com>
| | Date: Fri Feb 24 15:30:33 2023 +0900
| |
| | stash2
| |
* | commit 8ab1175562963245e883a025af8541b727e5bb24
| | Author: ssnhhyejin <ssnhhyejin@gmail.com>
| | Date: Fri Feb 24 19:30:00 2023 +0900
| |
| | modify-s1-funcb
| |
* | commit 5904b3e818ffc15a18e334267efcf507c6a56ef8
|/ Author: ssnhhyejin <ssnhhyejin@gmail.com>
| Date: Fri Feb 24 19:26:21 2023 +0900
|
| modified-s1
|
* commit 43bba6a4fe1bd2406e2f7376a6a618edd61b27c3
| Author: ssnhhyejin <ssnhhyejin@gmail.com>
| Date: Fri Feb 24 14:52:04 2023 +0900
|
| stash
|
* commit ea7d7063b456a507337aec3cf6e816aa1b7ace5f (bran)
|\ Merge: 507d420 55c71f6
| | Author: ssnhhyejin <ssnhhyejin@gmail.com>
โก๋ก๊ทธ ํ์ธ: ์ ์์ ์ผ๋ก merge ์๋ฃ๋จ