Introduction to Git
George Boorman
Curriculum Manager, DataCamp

การกู้คืนรีโพให้กลับสู่สถานะก่อน Commit ล่าสุด
git revert
a845edcb, ebe93178, ฯลฯHEAD, HEAD~1, ฯลฯgit revert HEAD
git revert HEAD

Ctrl + O แล้วกด EnterCtrl + X[main 7d11f79] Revert "Adding fresh data for the survey."
Date: Tue Jul 30 14:17:56 2024 +0000
1 file changed, 3 deletions(-)
git revert --no-edit HEAD
git revert -n HEAD
git revert ทำงานกับ Commit ไม่ใช่ไฟล์รายไฟล์
การย้อนกลับไฟล์เดียว:
git checkoutHEAD git checkout HEAD~1 -- report.md
git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: report.md
git commit -m "Checkout previous version of report.md"
[main daa6c87] Checkout previous version of report.md
1 file changed, 1 deletion(-)


git restore --staged summary_statistics.csv
git add summary_statistics.csv
git commit -m "Adding age summary statistics"
git restore --staged
| คำสั่ง | ผลลัพธ์ |
|---|---|
git revert HEAD |
ย้อนกลับไฟล์ทั้งหมดจาก Commit ที่ระบุ |
git revert HEAD --no-edit |
ย้อนกลับโดยไม่เปิด Text Editor |
git revert HEAD -n |
ย้อนกลับโดยไม่สร้าง Commit ใหม่ |
git checkout HEAD~1 -- report.md |
ย้อนกลับไฟล์เดียวจาก Commit ก่อนหน้า |
git restore --staged report.md |
นำไฟล์เดียวออกจาก Staging Area |
git restore --staged |
นำไฟล์ทั้งหมดออกจาก Staging Area |
Introduction to Git