Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การแก้ไขปัญหา >> Apple

วิธีแก้ 'Fatal: Origin does not appear to be a Git Repository' Error

Git คือ Distributed Version Control System ติดตามการเปลี่ยนแปลง Source Code GitHub เป็น Hosting Service ใช้ Git ทั้งคู่ใช้กันอย่างแพร่หลาย แต่พบรายงานว่า Mac Terminal รันคำสั่ง git ไม่ได้

วิธีแก้  Fatal: Origin does not appear to be a Git Repository  Error

บทความนี้อธิบายสาเหตุและวิธีแก้ ทำตามคำแนะนำอย่างแม่นยำ

สาเหตุ 'Fatal: Origin does not appear to be a Git Repository'

จากรายงาน สาเหตุคือ:

  • Missing Origin: Origin หายไป Origin คือ Reference ไปยัง GitHub Fork หายไป = คำสั่งบางอย่างทำงานไม่ได้
  • Incorrect URL: URL Config ของแอปผิด ต้องแก้ไข

วิธีที่ 1: เพิ่ม Origin

ถ้า Origin หาย ให้เพิ่มด้วยตนเอง:

  1. กด Command+Space พร้อมกัน
  2. พิมพ์ Terminal Enter
  3. วิธีแก้  Fatal: Origin does not appear to be a Git Repository  Error
  4. พิมพ์
    git remote -v
    Enter
  5. ดูว่ามี Remote ชื่อ Origin หรือไม่
  6. ถ้าไม่มี = Origin หาย
  7. เพิ่ม Origin:
    git remote add origin url/to/your/fork
  8. ตรวจสอบว่าแก้ได้

วิธีที่ 2: เปลี่ยน URL

ถ้า URL ผิด ให้เปลี่ยน:

  1. Command+Space > Terminal
  2. วิธีแก้  Fatal: Origin does not appear to be a Git Repository  Error
  3. รัน:
    git remote set-url origin ssh://git@github.com/username/newRepoName.git
  4. ตรวจสอบ

วิธีที่ 3: เปลี่ยน Origin เป็น Master

ถ้าต้อง Pull จาก Master ให้เปลี่ยน Origin เป็น Master ก่อน:

  1. Command+Space > Terminal
  2. วิธีแก้  Fatal: Origin does not appear to be a Git Repository  Error
  3. รัน:
    git pull origin master