ลบ Credential ที่บันทึกไว้ใน Git

  1. ลบ Credential ที่บันทึกไว้ใน Git: Git อาจเก็บข้อมูลบัญชีที่คุณเคยล็อกอินไว้ใน Credential Manager (สำหรับ Windows) หรือ Keychain (สำหรับ macOS) หรือตัวจัดการ Credential ของระบบปฏิบัติการอื่นๆคุณสามารถลบ Credential ที่บันทึกไว้โดยใช้คำสั่ง:
    git credential-manager-core erase

    หลังจากรันคำสั่งนี้ Git จะถามให้คุณล็อกอินใหม่เมื่อคุณพยายามใช้งานคำสั่งที่ต้องยืนยันตัวตนอีกครั้ง เช่น git push หรือ git clone

  2. สำหรับ macOS (Keychain):
    • เปิดแอป Keychain Access และค้นหาชื่อ git หรือ github.com
    • ลบรายการที่เกี่ยวข้องกับ Git หรือ GitHub ออก
  3. สำหรับ Windows (Credential Manager):
    • เปิด Credential Manager (ใน Control Panel)
    • เลือก Windows Credentials หรือ Generic Credentials
    • ค้นหารายการที่มีชื่อ git หรือ github.com
    • ลบ Credential นั้นออก
  4. เปลี่ยนข้อมูลบัญชี Git ที่ตั้งค่าไว้ใน global config: หากคุณต้องการเปลี่ยนข้อมูลบัญชี (ชื่อผู้ใช้หรืออีเมล) ที่ Git บันทึกไว้ใน global config ให้ใช้คำสั่งนี้:
    git config --global --unset user.name
    git config --global --unset user.email

    หลังจากนั้น ตั้งค่าบัญชีใหม่ด้วยคำสั่ง:

    git config --global user.name "Your New Username"
    git config --global user.email "Your New Email"

เมื่อทำขั้นตอนเหล่านี้แล้ว Git จะขอให้คุณล็อกอินใหม่ในการใช้งานคำสั่งที่ต้องยืนยันตัวตน