Git CLI
เข้าไปใน local folder ที่เราจะอัปเดทโค้ด เตรียมความพร้อมสำหรับ git
-git init
เชื่อม local เข้ากับ remote repository สร้าง repository ใน github
-git remote add origin <your_remote_https>
ทำประกาศการเลือก folder หรือไฟล์ที่เราจะให้ git ทำการติดตามการเปลี่ยนแปลง
-git add pages/*
ทำการ commit การเปลี่ยนแปลงใน local
-git commit -m “commit message”
ทำการอัปเดทโค้ด local ขึ้น remote github
-git push -u origin master
กรณีต้องการอัปเดทโค้ดจาก remote มายัง local
-git pull origin master
กรณีใช้งาน Branch
$ git branch
$ git checkout -b [name_of_your_new_branch]
$ git checkout [name_of_your_new_branch]
$ git add .
$ git commit -m “commit branch”
$ git push origin [name_of_your_new_branch]
สรุปคำสั่งที่ใช้บ่อย
git status
//check สถานะ
git remote add origin
https://github.com/user/repo.git //add remote git
git remote show origin
//เช็ค url remote git ชื่อ origin
git remote -v
//ดู remote url and name git
git pull origin master — allow-unrelated-histories
//merge ข้อมูล local กับ remote
git commit -m “commit”
//ยืนยันการเปลี่ยนแปลงล่าสุดเพื่อจะอัปขึ้น remote git
git push -u origin master
//อัปโหลดขึ้น remote git
วิธีการสร้าง Deploy Key เพื่อใส่ใน github
เพื่อใช้ในการอัปโหลดโค้ดขึ้น github ก่อนอื่นเราต้องทำการติดตั้ง gitbash ให้เรียบร้อยก่อนน่ะครับ

จากนั้นเข้าไปที่ folder ที่เราติดตั้ง gitbash เปิด command prompt ใน folder ดังกล่าว

จากนั้นพิพม์ ssh-keygen -t rsa -b 4096 -C “
[email protected]”

แล้วใส่รหัสผ่านและยืนยันให้เรียบร้อย

จากนั้นเปิดไฟล์ .pub คือ public key ที่เราจะเอาไปใส่ใน github

แล้วก็วางในส่วนของ Deploy keys กด Add key ก็เป็นอันเสร็จพิธีแล้วครับ
https://medium.com/@aegkaluk/%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-deploy-keys-%E0%B8%82%E0%B8%AD%E0%B8%87-github-67f6ff7b5ae7