การ push ไปยัง remote

Git ระดับกลาง

George Boorman

Curriculum Manager, DataCamp

การ pull จาก remote

pull จาก remote repository

Git ระดับกลาง

การ push ไปยัง remote

push ไปยัง remote

Git ระดับกลาง

git push

  • บันทึกการเปลี่ยนแปลงในเครื่องก่อน!
git push remote local_branch
  • Push เข้าสู่ remote จาก local_branch

  • Push การเปลี่ยนแปลงเข้าสู่ origin จาก branch main ในเครื่อง

git push origin main
Git ระดับกลาง

ขั้นตอน push/pull

pull จาก remote เข้าสู่ local repo

Git ระดับกลาง

ขั้นตอน push/pull

ทำงานกับโปรเจกต์ในเครื่อง

Git ระดับกลาง

ขั้นตอน push/pull

push local repository ที่อัปเดตแล้วไปยัง remote

Git ระดับกลาง

Push ก่อน

  • Push main ไปยัง remote ก่อน pull
git push origin main
Git ระดับกลาง

ความขัดแย้งระหว่าง remote กับ local

ผลลัพธ์การปฏิเสธ git push origin main

Git ระดับกลาง

ความขัดแย้งระหว่าง remote กับ local

ผลลัพธ์การปฏิเสธ git push origin main พร้อมระบุ remote URL

Git ระดับกลาง

ความขัดแย้งระหว่าง remote กับ local

ผลลัพธ์การปฏิเสธ git push origin main พร้อมระบุผลลัพธ์

Git ระดับกลาง

ความขัดแย้งระหว่าง remote กับ local

ผลลัพธ์การปฏิเสธ git push origin main พร้อมระบุสาเหตุและคำแนะนำ

Git ระดับกลาง

การหลีกเลี่ยงความขัดแย้ง

  • Pull จาก remote ก่อน
git pull origin main

git_pull_nano_editor.gif

Git ระดับกลาง

การ pull โดยไม่แก้ไขข้อความ

git pull --no-edit origin main
  • ไม่แนะนำ เว้นแต่มั่นใจในประวัติของโปรเจกต์เป็นอย่างดี!
Git ระดับกลาง

การ push branch ใหม่จาก local

  • กำลังทำงานใน branch hotfix ในเครื่อง

  • hotfix ยังไม่มีอยู่ใน remote

Git ระดับกลาง

การสร้าง branch ใหม่บน remote

  • hotfix มีอยู่เฉพาะในเครื่อง
git push origin hotfix
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 349 bytes | 349.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'hotfix' on GitHub by visiting:
remote:      https://github.com/datacamp/project/pull/new/hotfix
remote: 
To https://github.com/datacamp/project
 * [new branch]      hotfix -> hotfix
branch 'hotfix' set up to track 'origin/hotfix'.
Git ระดับกลาง

มาฝึกกันเถอะ!

Git ระดับกลาง

Preparing Video For Download...