From c05c2e51639c14ff1a87e6e37fbe15352a1fc291 Mon Sep 17 00:00:00 2001
From: suthee git - the simple guide
中文,
한국어
Vietnamese
+ ภาษาไทย
please report issues on github
นี่คือคู่มือการใช้ Git แบบง่ายๆ - ไม่ได้โม้ด้วย ;)
+ Tweet + + +
+
+
+
+ สร้าง directory ใหม่ก่อน, เปิดเข้าไปแล้วพิมพ์
+ git init
+ เพื่อสร้างฐานข้อมูล git ตัวใหม่
+
+ สร้างสำเนาฐานข้อมูลใหม่ โดยพิมพ์คำสั่ง
+ git clone /path/to/repository
+ ถ้าฐานข้อมูลอยู่บนเซิฟเวอร์ คุณต้องพิมพ์
+ git clone username@host:/path/to/repository
+
+ ฐานข้อมูลของคุณจะมี "tree" อยู่สามอันที่ถูกดูแลด้วย git
+ ตัวแรกคือ Working Directory ซึ่งเก็บไฟล์ทั้งหมดไว้
+ ตัวที่สองคือ Index ซึ่งเป็นพื้นที่สำหรับ staging (ลำดับการเปลี่ยนแปลงของข้อมูล) และ
+ สุดท้ายคือ HEAD ซึ่งจะชี้ไปยังการบันทึกข้อมูล (commit) ครั้งสุดท้ายของคุณ
+
+
+ คุณสามารถเสนอการเปลี่ยนข้อมูลหรือไฟล์ (โดยใส่ไว้ใน Index) ด้วยคำสั่ง
+ git add <filename>
+ git add *
+ นี่คือขั้นตอนแรกสำหรับขั้นตอนการทำงานของ git ถ้าจะบันทึก (commit) ข้อมูลเปลี่ยนใหม่ คุณจะต้องพิมพ์
+ git commit -m "Commit message"
+ ไฟล์ก็จะถูกบันทึกลงบน HEAD แต่ยังไม่ได้บันทึกลงฐานข้อมูลบนเซิฟเวอร์
+
+ ข้อมูลใหม่ยังอยู่บน HEAD ของฐานข้อมูลส่วนตัว ถ้าคุณต้องการจะส่งข้อมูลที่เปลี่ยนใหม่ไปยังฐานข้อมูลบนเซิฟเวอร์ ทำตามคำสั่งนี้
+ git push origin master
+ เปลี่ยนคีย์เวิร์ด master เป็น branch ที่คุณต้องการจะส่งข้อมูลไป
+
+ ถ้าคุณยังไม่ได้ทำสำเนาของฐานข้อมูลแต่ว่าคุณต้องการจะเชื่อมฐานข้อมูลนี้กับเซิฟเวอร์ คุณต้องพิมพ์ตามนี้
+ git remote add origin <server>
+ คุณก็จะสามารถส่งข้อมูลที่เปลี่ยนใหม่ไปยังเซิฟเวอร์ที่คุณต้องการได้
+
+
+ Branches เป็นที่ใช้สำหรับพัฒนา features ตัวใหม่โดยไม่ต้องรบกวนตัวอื่น master branch เป็น "default" branch (บร้านที่ถูกเลือกโดยอัตโนมัติ) เมื่อคุณสร้างฐานข้อมูลครั้งแรก คุณต้องใช้ branches ตัวอื่นสำหรับการพัฒนาอย่างอื่นและ merge พวกมันกลับเข้ามาที่ master branch เมื่อพัฒนาเสร็จแล้ว +
+
+
+ สร้าง branch ใหม่ชื่อ "feature_x" และเริ่มใช้มัน โดยต้องพิมพ์
+ git checkout -b feature_x
+ เปลี่ยนกลับมาที่ตัวมาสเตอร์ (master)
+ git checkout master
+ และลบ branch ทิ้ง
+ git branch -d feature_x
+ คนอื่นจะ ไม่สามารถใช้ branch ของคุณได้จนกว่าคุณจะส่งตัว branch ของคุณไปยังฐานข้อมูลบนเซิฟเวอร์
+ git push origin <branch>
+
+ จะอัพเดทฐานข้อมูลส่วนตัวให้มีข้อมูลใหม่จากเซิฟเวอร์ คุณต้องพิมพ์
+ git pull
+ ใน directory ปัจจุบัน เพื่อจะได้ดึงข้อมูล (fetch) และ รวบรวมข้อมูล (merge) จากฐานข้อมูลบนเซิฟเวอร์
+ to merge another branch into your active branch (e.g. master), use
+ git merge <branch>
+ in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in conflicts.
+ You are responsible to merge those conflicts
+ manually by editing the files shown by git. After changing, you need to mark them as merged with
+ git add <filename>
+ before merging changes, you can also preview them by using
+ git diff <source_branch> <target_branch>
+
+ it's recommended to create tags for software releases. this is a known concept, which also exists in SVN. You can create a new tag named 1.0.0 by executing
+ git tag 1.0.0 1b2e1d63ff
+ the 1b2e1d63ff stands for the first 10 characters of the commit id you want to reference with your tag. You can get the commit id by looking at the...
+
+ in its simplest form, you can study repository history using..
+ git log
+ You can add a lot of parameters to make the log look like what you want. To see only the commits of a certain author:
+ git log --author=bob
+ To see a very compressed log where each commit is one line:
+ git log --pretty=oneline
+ Or maybe you want to see an ASCII art tree of all the branches, decorated with the names of tags and branches:
+ git log --graph --oneline --decorate --all
+ See only which files have changed:
+ git log --name-status
+ These are just a few of the possible parameters you can use. For more, see
+ git log --help
+
+ In case you did something wrong, which for sure never happens ;), you can replace local changes using the command
+ git checkout -- <filename>
+ this replaces the changes in your working tree with the last content in HEAD. Changes already added to the index, as well as new files, will be kept.
+
+ If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it like this
+ git fetch origin
+ git reset --hard origin/master
+
+ built-in git GUI
+ gitk
+ use colorful git output
+ git config color.ui true
+ show log on just one line per commit
+ git config format.pretty oneline
+ use interactive adding
+ git add -i
+
+
+
+ ++
+ +
- ฐานข้อมูลของคุณจะมี "tree" อยู่สามอันที่ถูกดูแลด้วย git
- ตัวแรกคือ Working Directory ซึ่งเก็บไฟล์ทั้งหมดไว้
- ตัวที่สองคือ Index ซึ่งเป็นพื้นที่สำหรับ staging (ลำดับการเปลี่ยนแปลงของข้อมูล) และ
- สุดท้ายคือ HEAD ซึ่งจะชี้ไปยังการบันทึกข้อมูล (commit) ครั้งสุดท้ายของคุณ
+ ฐานข้อมูลของคุณจะมี "tree" อยู่สามอันที่ถูกดูแลด้วย git ซึ่ง
+ tree ตัวแรกคือ Working Directory จะเก็บไฟล์ทั้งหมดไว้ จากนั้น
+ tree ตัวที่สองคือ Index จะเป็นพื้นที่สำหรับ staging (ลำดับการเปลี่ยนแปลงของข้อมูล) และ
+ tree สุดท้ายคือ HEAD ซึ่งจะชี้ไปยังการบันทึกข้อมูลครั้งสุดท้าย
git add <filename>git add *git commit -m "Commit message"
สร้าง branch ใหม่ชื่อ "feature_x" และเริ่มใช้มัน โดยต้องพิมพ์
git checkout -b feature_x
- เปลี่ยนกลับมาที่ตัวมาสเตอร์ (master)
+ เปลี่ยนมาเป็นตัวมาสเตอร์
git checkout master
และลบ branch ทิ้ง
git branch -d feature_x
- คนอื่นจะ ไม่สามารถใช้ branch ของคุณได้จนกว่าคุณจะส่งตัว branch ของคุณไปยังฐานข้อมูลบนเซิฟเวอร์
+ คนอื่นจะ ไม่สามารถใช้ branch ของคุณได้จนกว่าคุณจะส่งตัว branch ของคุณไปยังฐานข้อมูลบนเซิฟเวอร์ ให้ทำตามนี้
git push origin <branch>
git pullgit merge <branch>git add <filename>git diff <source_branch> <target_branch>
- it's recommended to create tags for software releases. this is a known concept, which also exists in SVN. You can create a new tag named 1.0.0 by executing
+ แนะนำให้คุณสร้างแท๊กทุกครั้งที่เปิดตัวซอร์ฟแวร์ วิธีการนี้เรียกว่า concept ซึ่ง SVN ก็มีเช่นกัน คุณสร้างแท๊กตัวใหม่ ชื่อ 1.0.0 โดยพิมพ์คำสั่ง
git tag 1.0.0 1b2e1d63ff
- the 1b2e1d63ff stands for the first 10 characters of the commit id you want to reference with your tag. You can get the commit id by looking at the...
+ 1b2e1d63ff คืออักษร 10 ตัวแรกจากไอดีการบันทึก (commit id) ที่คุณต้องการจะเชื่อมกับแท๊ก คุณสามารถหาไอดีการบันทึกได้จาก...
- in its simplest form, you can study repository history using..
+ คุณสามารถดูประวัติของฐานข้อมูลได้โดยคำสั่ง..
git log
- You can add a lot of parameters to make the log look like what you want. To see only the commits of a certain author:
+ คุณสามารถใส่พารามีเตอร์ไปยังล็อกเพื่อให้มันแสดงผลลัพธ์ที่คุณต้องการ ถ้าอยากจะได้ประวัติการบันทึกของโปรแกรมเมอร์คนใดคนหนึ่ง คุณพิมพ์:
git log --author=bob
- To see a very compressed log where each commit is one line:
+ ถ้าอยากได้ล็อกที่สั้นๆโดยประวัติการบันทึกถูกจดไว้ในแต่ละแถว ใช้คำสั่ง:
git log --pretty=oneline
- Or maybe you want to see an ASCII art tree of all the branches, decorated with the names of tags and branches:
+ หรือถ้าอยากจะเห็นรูปวาด ASCII art tree ของบร้านทุกตัว โดยมีชื่อกับแท้ก ต้องพิมพ์:
git log --graph --oneline --decorate --all
- See only which files have changed:
+ อยากจะเห็นเพียงไฟล์ถูกเปลี่ยน:
git log --name-status
- These are just a few of the possible parameters you can use. For more, see
+ ที่บอกมานี่ยังเป็นแค่ส่วนหนึ่งของพารามีเตอร์เท่านั้น อยากจะรู้มากกว่านี้ ไปเปิดดูที่
git log --help
- In case you did something wrong, which for sure never happens ;), you can replace local changes using the command
+ บางทีคุณอาจจะทำข้อมูลเสียหาย ซึ่งก็ไม่เกิดขึ้นหรอกนะ ;), คุณสามารถเริ่มข้อมูลใหม่ได้โดยแทนค่าข้อมูลเก่าด้วยคำสั่ง
git checkout -- <filename>
- this replaces the changes in your working tree with the last content in HEAD. Changes already added to the index, as well as new files, will be kept.
+ คำสั่งนี้แทนข้อมูลใน working tree ด้วยข้อมูลจาก HEAD ข้อมูลที่ถูกเปลี่ยนก็ได้บันทึกลงบน index และไฟล์ใหม่ก็ถูกบันทึกด้วย
- If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it like this
+ แต่ถ้าคุณอยากจะทิ้งข้อมูลใหม่ทั้งหมดที่คุณสร้างและก็บันทึกไว้ด้วย คุณควรจะดึงข้อมูลล่าสุดจากเซิฟเวอร์และก็เชื่อมต่อกับ master branch ส่วนตัวของคุณ โดยทำตามนี้
git fetch origin
git reset --hard origin/master
built-in git GUI
gitk
- use colorful git output
+ ตกแต่งผลลัพธ์ของ git ด้วยสีสวยๆ
git config color.ui true
- show log on just one line per commit
+ แสดงผลการบันทึกอย่างละบรรทัดบนล็อก
git config format.pretty oneline
- use interactive adding
+ เพิ่มไฟล์แบบ interactive
git add -i
just a simple guide for getting started with git. no deep shit ;)
+ Tweet + + +
+
+
+
+ create a new directory, open it and perform a
+ git init
+ to create a new git repository.
+
+ create a working copy of a local repository by running the command
+ git clone /path/to/repository
+ when using a remote server, your command will be
+ git clone username@host:/path/to/repository
+
+ your local repository consists of three "trees" maintained by git.
+ the first one is your Working Directory which holds the actual files.
+ the second one is the Index which acts as a staging area and
+ finally the HEAD which points to the last commit you've made.
+
+
+ You can propose changes (add it to the Index) using
+ git add <filename>
+ git add *
+ This is the first step in the basic git workflow. To actually commit these changes use
+ git commit -m "Commit message"
+ Now the file is committed to the HEAD, but not in your remote repository yet.
+
+ Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute
+ git push origin master
+ Change master to whatever branch you want to push your changes to.
+
+ If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with
+ git remote add origin <server>
+ Now you are able to push your changes to the selected remote server
+
+
+ Branches are used to develop features isolated from each other. The master branch is the "default" branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion. +
+
+
+ create a new branch named "feature_x" and switch to it using
+ git checkout -b feature_x
+ switch back to master
+ git checkout master
+ and delete the branch again
+ git branch -d feature_x
+ a branch is not available to others unless you push the branch to your remote repository
+ git push origin <branch>
+
+ to update your local repository to the newest commit, execute
+ git pull
+ in your working directory to fetch and merge remote changes.
+ to merge another branch into your active branch (e.g. master), use
+ git merge <branch>
+ in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in conflicts.
+ You are responsible to merge those conflicts
+ manually by editing the files shown by git. After changing, you need to mark them as merged with
+ git add <filename>
+ before merging changes, you can also preview them by using
+ git diff <source_branch> <target_branch>
+
+ it's recommended to create tags for software releases. this is a known concept, which also exists in SVN. You can create a new tag named 1.0.0 by executing
+ git tag 1.0.0 1b2e1d63ff
+ the 1b2e1d63ff stands for the first 10 characters of the commit id you want to reference with your tag. You can get the commit id by looking at the...
+
+ in its simplest form, you can study repository history using..
+ git log
+ You can add a lot of parameters to make the log look like what you want. To see only the commits of a certain author:
+ git log --author=bob
+ To see a very compressed log where each commit is one line:
+ git log --pretty=oneline
+ Or maybe you want to see an ASCII art tree of all the branches, decorated with the names of tags and branches:
+ git log --graph --oneline --decorate --all
+ See only which files have changed:
+ git log --name-status
+ These are just a few of the possible parameters you can use. For more, see
+ git log --help
+
+ In case you did something wrong, which for sure never happens ;), you can replace local changes using the command
+ git checkout -- <filename>
+ this replaces the changes in your working tree with the last content in HEAD. Changes already added to the index, as well as new files, will be kept.
+
+ If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it like this
+ git fetch origin
+ git reset --hard origin/master
+
+ built-in git GUI
+ gitk
+ use colorful git output
+ git config color.ui true
+ show log on just one line per commit
+ git config format.pretty oneline
+ use interactive adding
+ git add -i
+
+
+
+ ++
+ +
comments
+ + + +