Skip to content

Instantly share code, notes, and snippets.

@teerasej
Last active November 7, 2021 14:50
Show Gist options
  • Save teerasej/514c5b7d21d0964eccf08bccd555457c to your computer and use it in GitHub Desktop.
Save teerasej/514c5b7d21d0964eccf08bccd555457c to your computer and use it in GitHub Desktop.
วิธีตั้งโปรเจค git เข้า Remote H

วิธีตั้งโปรเจค git เข้า Remote Host

วิธีตั้งค่า Proxy ให้ Git

เราสามารถตั้งค่า Proxy ให้ Git ได้ด้วยคำสั่งนี้ ผ่าน Command Line

	git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

เปลี่ยนข้อมูลในคำสั่งตามรายละเอียดด้านล่าง

  • proxyuser : ชื่อ proxy user ของเรา
  • proxypwd :รหัสผ่าน proxy ของเรา
  • proxy.server.com : URL ของ Proxy Server
  • 8080 : Port ของ Proxy Server

วิธีเชื่อมโปรเจคบนเครื่องเข้าสู่ Github

1. จัดการ Commit ไฟล์ในโปรเจคให้พร้อม

การเตรียมเชื่อมโปรเจคบนเครื่องของเราเข้าสู่ Github จะเริ่มจากการ Commit ไฟล์ในโปรเจคก่อน

  1. เปิดโฟลเดอร์โปรเจคด้วย Command Line
  2. ใช้คำสั่ง git status เพื่อเช็คสถานะของโปรเจค
    • ใช้คำสั่ง git init ถ้ายังไม่มี git คุมโปรเจคของเรา
    • สร้างไฟล์ gitignore ตามวิธีการนี้
  3. ใช้คำสั่ง git add --all เพื่อเพิ่มไฟล์ที่เข้าสถานะ Change ทั้งหมดเป็น Staged
  4. ใช้คำสั่ง git commit -m "First commit" เพื่อสั่ง commit ไฟล์ทั้งหมดใน Staged

2.1 ระบุชื่อ Git Account ในการใช้ครั้งแรก

หากเป็นการใช้ Git ครั้งแรกบนเครื่องเราระบบอาจจะแจ้งให้เรากรอกข้อมูลด้วยคำสั่งต่อไปนี้

	git config --global user.email "อีเมลล์ที่สมัคร Github"
	git config --global user.name "ชื่อ username ที่ใช้บน Github"

รันคำสั่งพร้อมข้อมูลดังกล่าวให้เรียบร้อย

3. กำหนด Remote URI ให้ Git ในโปรเจคของเรา

จากนั้น

  1. ใช้คำสั่ง git remote add origin [remote repository URL] โดยให้แทนที่ remote repository URL เป็น URL ของ Repository บน Github ที่เราสร้างไว้
  2. ใช้คำสั่ง git remote -v เพื่อเช็คสถานะ
  3. ให้คำสั่ง git push -u origin master เพื่อส่งไฟล์ที่ Commit แล้วในโปรเจคขึ้น Github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment