Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

how to resolve git conflict - basic

Scenario

คุณกำลังโปรเจคเปลี่ยนโลกกับเพื่อนๆอยู่ แต่ว่าเพื่อนแอบเพิ่มไฟล์สุด เจ๋ง เข้าไปในโปรเจคของคุณ คุณพยายามจะ push ไฟล์ของคุณขึ้นไปแต่เพื่อนของคุณก็พยายาม push ไฟล์ของเขาขึ้นไปด้วย จนทำให้เกิด conflict ขึ้นคุณจะทำอย่างไร?

Divergent Push

Setup

Person 1

File: p1_file.txt

echo "Hi, I am P1. I want to add some cool stuff!" >> p1_file.txt

Person 2

File: p2_file.txt

echo "Hi, I am P2. I want to add some cool stuff too!" >> p2_file.txt

Steps

  1. Person 1 ทำการ push ไฟล์ของตัวเองขึ้นไป
git add p1_file.txt
git commit -m "p1 add cool stuff!"
git push origin main
  1. Person 2 ทำการ push ไฟล์ของตัวเองขึ้นไป
git add p2_file.txt
git commit -m "p2 add cool stuff!"
git push origin main

Note

Person 2 จะพบ conflict ขึ้นหลังจากทำการ push ไฟล์ของตัวเองขึ้นไป

About

S: Someone pushed a commit to the same branch as you, but you haven't pulled it yet. What are you going to do?

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Contributors