การใช้ GitHub เบื้องต้น

Wandee Srepenrak
Jul 26, 2017 · 2 min read

การใช้ Github เบื้องต้น โดยละเอียด

อย่างแรกที่ควรรู้ เบื้องต้น Github คืออะไร ?

Github คือ Version Control ตัวนึง แล้ว Version Control คืออะไร ?

ตอบ https://kmi.tl/Pqe6D

Dowload => https://git-scm.com/

  • เปิด Git Bash ขึ้นมา (ต้อง Dowload จากลิ้งด้านบนก่อน )

แล้วก็ไปที่ Directory ของ Project ของเรา โดยใช้ คำสั้ง “cd”

  • แล้วก็พิมคำสั้งตามนี้
  • “ git init ” คำสั่งนี้จะสร้างแฟ้มข้อมูลย่อยชื่อ .git ซึ่งเก็บแฟ้มโครงสร้างของ Git repository เปล่า ๆ ที่ยังไม่มีเนื้อหาใด
  • “git add * ” คำสั้งนี้ คือการเพิ่มไฟล์ทุกไฟล์ลงใน ข้อมูลย่อยชื่อ .git
  • “ git commit –m “save data” ” ก็คือการเก็บข้อมูลประวัติไฟล์ เรียกได้ว่าเป็นการ save version นั้นเอง

• ต่อไปเราจะนำขึ้นไป บน GitHub

เริ่มต้นใช้งาน

Create repository
  • เมื่อสร้าง Repository เรียบร้อยแล้วก็จะได้ลิ้ง Github มา

แล้วก็ใช้คำสั้งต่อไปนี้ เพื่อนำข้อมูลขึ้นบน Server GitHub

  • “git remote add origin {ลิ้ง}” คำสั้งนี้เป็นการบอกที่อยู่ของ server ที่จะอัพข้อมูลขึ้นไป
  • “git push -u origin master ” คำสั้งนี้เป็นการนำไฟล์อัพขึ้นไปบน server ที่ master (คำสั้งนี้ใช้ครั้งเดียว ครั้งต่อไปใช้แค่ git push)

Option

  • “git clone {ลิ้ง}” คือการโหลดข้อมูลจาก ลิ้ง git ลงมา
  • “git pull” คือการอัพเดพข้อมูลโปรเจคลงมาในเครื่องเรา ให้ตรงกับบน server
  • “git status” ไว้เช็คสถานะ

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade