0Pricing
Linux Command Line Mastery · บทเรียน

การแตกแขนงและผสานด้วย Git จากบรรทัดคำสั่ง

ต่อยอดพื้นฐาน Git ด้วยการทำงานกับสาขา: สร้าง เปลี่ยนสาขา ผสาน แก้ข้อขัดแย้ง และปฏิบัติตามเวิร์กโฟลว์สาขาฟีเจอร์ที่เป็นระเบียบ

การแตกแขนงและผสานด้วย Git จากบรรทัดคำสั่ง เป็นบทเรียน Linux Command Line Mastery ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Linux Command Line Mastery และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Linux Command Line Mastery มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Branches?

You know how to commit and track files. Branches let you develop features in isolation without disturbing the main line of work, then merge them back when ready.

Listing Branches

git branch lists branches and marks the current one with an asterisk.

git branch

Creating and Switching

git switch -c name creates a branch and moves to it in one step. (Older Git uses git checkout -b.)

git switch -c feature-login

Committing on a Branch

Commits you make now belong only to the feature branch, leaving main untouched.

git add .
git commit -m 'Add login form'

Switching Back

Return to main with git switch main. Your feature work is safely stored on its own branch.

git switch main

Merging a Branch

From main, git merge brings the feature commits in. A fast-forward happens when main has no new commits.

git merge feature-login

Handling Merge Conflicts

If the same lines changed on both branches, Git pauses and marks conflicts with <<<<<<< markers. Edit the file to resolve, then stage and commit.

git add resolved-file.txt
git commit

Deleting Merged Branches

After merging, clean up with git branch -d. Git refuses if the branch is not merged, protecting your work.

git branch -d feature-login

Comparing Branches

git diff between branches shows exactly what differs before you merge.

git diff main..feature-login

Pushing a Branch

Share a branch by pushing it and setting upstream tracking with -u.

git push -u origin feature-login

A Clean Workflow

The feature-branch loop: branch from main, commit, push, open a pull request, merge, delete the branch. This keeps history organized and reviewable.

Quick Check

Which single command both creates a new branch and switches to it?

Recap

You can now manage parallel work:

  • git switch -c creates and moves to a branch
  • git merge integrates; conflicts are resolved by editing then committing
  • git branch -d cleans up merged branches
  • git push -u origin shares them

Branch per feature, merge when done.

คำถามที่พบบ่อย

บทเรียน “การแตกแขนงและผสานด้วย Git จากบรรทัดคำสั่ง” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การแตกแขนงและผสานด้วย Git จากบรรทัดคำสั่ง” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Linux Command Line Mastery ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Linux Command Line Mastery มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การแตกแขนงและผสานด้วย Git จากบรรทัดคำสั่ง”

ต่อยอดพื้นฐาน Git ด้วยการทำงานกับสาขา: สร้าง เปลี่ยนสาขา ผสาน แก้ข้อขัดแย้ง และปฏิบัติตามเวิร์กโฟลว์สาขาฟีเจอร์ที่เป็นระเบียบ คุณปฏิบัติ Linux Command Line Mastery ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Linux Command Line Mastery หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Linux Command Line Mastery บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “การแตกแขนงและผสานด้วย Git จากบรรทัดคำสั่ง” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Linux Command Line Mastery นี้ได้ไหม

ได้ บทเรียน Linux Command Line Mastery ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. พื้นฐาน Git จากบรรทัดคำสั่ง
  2. ตัวแปรสภาพแวดล้อมและนามแฝง
  3. การกำหนดค่าเชลล์: `.bashrc`, `.zshrc`, `.profile`
  4. การแตกแขนงและผสานด้วย Git จากบรรทัดคำสั่ง
← กลับไปที่ Linux Command Line Mastery