วิธีสร้าง Git Repo จาก Local ไปยัง Remote ด้วย Command
Published in
1 min readOct 4, 2018
cd เข้าไปในโฟลเดอร์โปรเจค
cd ~/your-project-folder
สร้าง git repo ขึ้นมาก่อนด้วยคำสั่ง
git init
stage ไฟล์ทั้งหมดเพื่อจะส่งไปยัง remote
git add .
(ถ้าใครจะเอาบางไฟล์ก็ให้เลือก add ทีละไฟล์ก็เปลี่ยน . เป็นชื่อไฟล์หรือ * เอานะครับ)
Commit ไฟล์ชุดแรกที่ Stage เอาไว้ ตั้งชื่อตามต้องการเลย
git commit -m "Initial commit"
สร้าง Remote repo และเพิ่มไว้ในตั้งค่าไว้เพื่อใช้ push ต่อไป
git remote add origin [email protected]:your-username/your-repository.git
สุดท้ายก็ push ไฟล์ที่ Commit ไว้ไปยัง Remote ครับ
git push -u origin master
(มันจะถาม username กับ password ก็ใส่ให้ถูกต้องนะครับ)
ลอง login เข้าไปดูที่ Git Remote ของเรา ก็จะเจอ Repo ใหม่ที่พึ่งเราสร้างจาก Local เป็นที่เรียบร้อย
Originally published at ideagital.com.