วันเสาร์ที่ 30 กันยายน พ.ศ. 2566

Git Command

  • เริ่มต้นสร้าง Git repository หรือสร้างโฟลเดอร์ .git (hidden folder) ด้วยคำสั่ง
  • git init

  • เพิ่มไฟล์เข้าไปใน staging area ด้วยคำสั่ง
git add <file name> หรือ git add . เพื่อ add ไฟล์ทั้งหมด
  • Commit ไฟล์ไปยัง local repository ด้วยคำสั่ง
git commit -m "<commit-message>"
  • ตรวจสอบ remote repositoty ด้วยคำสั่ง
git remote -v
  • Add remote repositoty ด้วยคำสั่ง
git remote add <remote-name> <remote-url>
  • เปลี่ยน remote url ด้วยคำสั่ง
git remote set-url <remote-name> <new-remote-url>
  • ลบ remote reposity ด้วยคำสั่ง
git remote rm <remote-name>
  • ตรวจสอบ branch ปัจจุบันด้วยคำสั่ง
git branch
  • ตรวจสอบ branch ทั้งหมดด้วยคำสั่ง
git branch -a
  • เปลี่ยนชื่อ branch ปัจจุบันด้วยคำสั่ง
git branch -M <new-branch-name>
  • สร้าง branch ใหม่ด้วยคำสั่ง
git branch <new-branch-name>
  • เปลี่ยน branch ปัจจุบันด้วยคำสั่ง
git checkout <branch-name>
  • ลบ local branch ด้วยคำสั่ง
git branch -d <branch-name>
  • ลบ remote branch ด้วยคำสั่ง
git push <remote-name> --delete <branch-name>
  • Push local reposity ไปยัง remote reposity ด้วยคำสั่ง
git push -u <remote-name> <branch-name>
  • Clone remote repository ไปยัง local reposity ด้วยคำสั่ง
git clone <remote-url>
  • ดึงการอัพเดทล่าสุดจาก remote repository ด้วยคำสั่ง 
git pull