Git Staging Environment
Git Staging Environment
หนึ่งในหน้าที่หลักของ Git คือแนวคิดของ Staging Environment และ Commit
ขณะที่คุณทำงาน คุณอาจกำลังเพิ่ม แก้ไข และลบไฟล์ แต่เมื่อใดก็ตามที่คุณบรรลุเป้าหมายหรืองานบางส่วนเสร็จสิ้น คุณควรเพิ่มไฟล์ไปยัง Staging Environment
ไฟล์แบบส เตจคือไฟล์ที่พร้อมจะ คอม
มิตกับที่เก็บที่คุณกำลังทำงานอยู่ คุณจะได้เรียนรู้เพิ่มเติม
commit
ในไม่ช้า
สำหรับตอนนี้ เราเสร็จสิ้นการทำงานกับindex.html
. ดังนั้นเราจึงสามารถเพิ่มไปยัง Staging Environment:
ตัวอย่าง
git add index.html
ไฟล์ควรเป็นStaged มาเช็คสถานะกัน::
ตัวอย่าง
git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
ตอนนี้ไฟล์ถูกเพิ่มไปยัง Staging Environment แล้ว
Git เพิ่มมากกว่าหนึ่งไฟล์
คุณยังสามารถจัดฉากได้มากกว่าหนึ่งไฟล์ในแต่ละครั้ง มาเพิ่มอีก 2 ไฟล์ในโฟลเดอร์การทำงานของเรา ใช้โปรแกรมแก้ไขข้อความอีกครั้ง
README.md
ไฟล์ที่อธิบายที่เก็บ (แนะนำสำหรับที่เก็บทั้งหมด) :
ตัวอย่าง
# hello-world
Hello World repository for Git tutorial
This is an
example repository for the Git tutoial on https://www.w3schools.com
This repository is built step by step in the tutorial.
สไตล์ชีตภายนอกพื้นฐาน ( bluestyle.css
):
ตัวอย่าง
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
และอัปเดตindex.html
เพื่อรวมสไตล์ชีต:
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
<link
rel="stylesheet" href="bluestyle.css">
</head>
<body>
<h1>Hello world!</h1>
<p>This is
the first file in my new Git Repo.</p>
</body>
</html>
เพิ่มไฟล์ทั้งหมดในไดเร็กทอรีปัจจุบันไปยัง Staging Environment:
ตัวอย่าง
git add --all
การใช้--all
แทนชื่อไฟล์แต่ละไฟล์จะstage
เปลี่ยนแปลงไฟล์ทั้งหมด (ใหม่ แก้ไข และลบ)
ตัวอย่าง
git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README.md
new file: bluestyle.css
new file: index.html
ตอนนี้ทั้ง 3 ไฟล์ถูกเพิ่มไปยัง Staging Environment และเราพร้อมที่จะทำcommit
ไฟล์ .
หมายเหตุ:คำสั่งชวเลขสำหรับ
git add --all
isgit add -A