การสร้าง repo

Introduction to Git

George Boorman

Curriculum Manager, DataCamp

โปรเจกต์สุขภาพจิตในวงการเทค

ภาพ Git repository ที่มีไฟล์สองไฟล์ชื่อ funding และ report หนึ่งไดเรกทอรีชื่อ data และอีกหนึ่งชื่อ dot-git

Introduction to Git

Git repo คืออะไร?

  • Git repo = ไดเรกทอรีที่ประกอบด้วยไฟล์และไดเรกทอรีย่อย

ภาพ Git repository พร้อมคำอธิบายไฟล์สองไฟล์ชื่อ funding และ report หนึ่งไดเรกทอรีชื่อ data และอีกหนึ่งชื่อ dot-git

Introduction to Git

Git repo คืออะไร?

  • Git repo = ไดเรกทอรีที่ประกอบด้วยไฟล์ ไดเรกทอรีย่อย และพื้นที่เก็บข้อมูลของ Git

ภาพ Git repository พร้อมคำอธิบายไฟล์สองไฟล์ชื่อ funding และ report หนึ่งไดเรกทอรีชื่อ data และอีกหนึ่งชื่อ dot-git ซึ่งระบุว่าเป็นพื้นที่เก็บข้อมูลของ Git

ห้ามแก้ไข .git!

Introduction to Git

ประโยชน์ของ repo

  • ติดตามเวอร์ชันอย่างเป็นระบบ
  • ย้อนกลับไปยังเวอร์ชันก่อนหน้า
  • เปรียบเทียบเวอร์ชันในแต่ละช่วงเวลา
  • ทำงานร่วมกับเพื่อนร่วมงาน

เพื่อนร่วมงานกำลังระดมความคิด

Introduction to Git

การสร้าง repo ใหม่

git init mental-health-workspace
cd mental-health-workspace
git status
On branch main

No commits yet

nothing to commit (create/copy files and use "git add" to track)
Introduction to Git

การแปลงโปรเจกต์เป็น repo

  • แปลงไดเรกทอรีที่มีอยู่ให้เป็น Git repo
git init
Initialized empty Git repository in /home/repl/mental-health-workspace/.git/
Introduction to Git

กำลังติดตามไฟล์ใดอยู่?

git status
On branch main

No commits yet

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

        data/
        report.md

nothing added to commit but untracked files present (use "git add" to track)
  • Git ตรวจพบว่ามีไฟล์ที่ถูกแก้ไขแต่ยังไม่ได้ติดตาม!
Introduction to Git

Nested repositories

  • อย่าสร้าง Git repo ซ้อนภายใน Git repo อื่น
    • เรียกว่า nested repos

 

  • จะมีไดเรกทอรี .git สองอัน

  • Git ควรอัปเดตไดเรกทอรี .git อันไหน?

 

สุนัขที่ดูสับสน

Introduction to Git

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

Introduction to Git

Preparing Video For Download...