Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> การเขียนโปรแกรม Bash

เริ่มต้นกับ Git: คู่มือ Setup ครั้งแรก

Git คือ Free and Open Source Distributed Version Control System

Git เป็น Version Control System ที่ใช้แพร่หลายที่สุดในโลกวันนี้ — Distributed และ Maintained อย่างต่อเนื่อง พัฒนาโดย Linus Torvalds (สร้าง Linux Kernel) ในปี 2005

ต่างจาก Centralized VCS (SVN, CVS): Git แบบ Distributed — ทุก Developer มี Full History ของ Code Repository อยู่ Local — ทำงานได้ดีบน OS และ IDEs หลากหลาย

บทความนี้: ติดตั้ง Git, Setup ครั้งแรก, Tips และ Resources เรียนรู้ต่อ — เริ่มเลย!

สมมติว่ารู้ Version Control แล้ว — ไม่อ่าน slide นี้ก่อน

Version Control คืออะไร? (Recap)

กระบวนการจัดการการเปลี่ยนแปลง Source Code หรือ Files ตามเวลา — เก็บทุก Modification ใน Database พิเศษ — หากผิดพลาด Restore/Compare Version ก่อนหน้าได้ → แก้ไขโดยไม่รบกวน Team

ติดตั้ง Git

macOS

  • Download Git for macOS
  • หรือ Homebrew: brew install git

Linux

  • Download Git for Linux
  • Debian/Ubuntu: sudo apt-get update && sudo apt-get upgrade && sudo apt-get install git
  • Red Hat/CentOS/Fedora: sudo yum upgrade && sudo yum install git

Windows

  • Download Git for Windows (Installer GUI)

Install Guide รายละเอียดบน Git Official Docs

ตั้งค่า Git Environment

Git มาพร้อม git config — Get/Set Config Variables ควบคุมรูปลักษณ์และการทำงาน

1. ตั้งค่าตนภาพ (Identity)

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

--global = ใช้ทุก Repository บนระบบนี้

2. ตั้งค่า Default Text Editor

git config --global core.editor vim

(ไม่บังคับ — ไม่ตั้งค่า Git จะใช้ Default Editor ของระบบ)

3. เปิดสีสำหรับ Git Console

git config --global color.ui true

color.ui = Meta Config รวม color.* ทั้งหมด — Linux Users ใช้ Oh My Zsh ปรับ Terminal Theme ได้อีก

ตรวจสอบการตั้งค่า

git config --list
user.name=Your Name
user.email=your.email@example.com
color.ui=true

อยากเรียนรู้ Git Commands เพิ่ม?

อ่านบทความ: Git Cheat Sheet — ครอบคำสั่ง Git สำคัญที่ต้องรู้

สรุป

Version Control เป็นส่วนจำเป็นของ Software Developer สมัยใหม่ — เมื่อคุ้นเคยกับ Benefits แล้ว หลาย Developer ไม่อยากทำงานโดยไม่มี VCS แม้โปรเจกต์ Non-Software ก็ตาม

เริ่มใช้ Git วันนี้ — คุ้มค่าเกินกว่าที่คิด!