สารบัญ
DokuWiki Git Repository
Source Code ของ DokuWiki ถูกจัดการผ่านระบบควบคุมเวอร์ชันชื่อ Git . Git เป็นระบบควบคุมเวอร์ััชันแบบกระจาย แบบฟรีและOpenSource ถูกออกแบบเพื่อจัดการทุกๆอย่างตั้งแต่เล็กๆไปยังโปรเจ็คขนาดใหญ่มากๆ ซึ่งมีการทำงานอย่างรวดเร็วและมีประสิทธิภาพ.
Git is NOT offered as optional version control backend for `DokuWiki` itself. Refer to closed (and not completed nor started) bounties.
วิธีการใช้ git
แทนที่จะทำสิ่งต่างๆซ้ำๆโดยการ กล่าวถึงสิ่งที่เคยมีคนพูดมาแล้วในที่อื่นๆ ผมเพียงแค่ให้ตัวชี้แก่คุณบางส่วนดังนี้:
There are also some good books about Git:
- Scott Chacon - Pro Git (ISBN 978-1-43021-833-3) – You can read it online for free (CC licensed). Translations are also available (e.g. German).
- Ben Lynn - Git Magic (ISBN 978-1-45152-334-8) – You can read it online for free (GPL licensed). Translations are also available (e.g. Spanish).
- Travis Swicegood - Pragmatic Version Control Using Git (ISBN 978-1-93435-615-9)
- Jon Loeliger - Version Control with Git (ISBN 978-0-59652-012-0)
git configuration
ก่อนคุณจะเริ่มใช้ git, คุณต้องตั้งค่ามันด้วยชื่อและ email address ของคุณ:
git config --global user.name "ชื่อคุณที่นี่" git config --global user.email you@yourdomain.example.com
และอาจเพิ่มเติมโดยการ เซ็ตค่าสี และ aliase อื่นๆเช่น:
git config --global color.ui auto git config --global alias.st status git config --global alias.ci commit git config --global alias.up pull --rebase
การใช้ git สำหรับ DokuWiki
ในการดึง version ของ DokuWiki ที่กำลังพัฒนาอยู่ในปัจจุบัน ให้ใช้สำคำสั่งดังนี้ (คำสั่งนี้จะสร้างโฟลเดอร์ dokuwiki ให้คุณ):
git clone git://github.com/splitbrain/dokuwiki.git
ในการปรับปรุงสิ่งที่ checkout มาแล้วให้ใช้คำสั่งนี้จากภายใน directory Dokuwiki :
git pull
เมื่้อเราได้สร้าง source file ใหม่ขึ้นมา , ให้ใช้คำสั่งนี้ในการเพิ่มไปยัง git repository:
git add somenewfile
เมื่อคุณได้แก้ไขไฟล์ทีุ่ถูก trackแล้ว บางไฟล์ , คุณต้องบอกว่ามีการแก้ไขกับ git ด้วยคำสั่ง:
git add --patch
The --patch
จะถามคุณว่า parts ไหนที่คุณต้องการ check in (คล้ายกับพฤติกรรมของดโปรแกม darcs มาก)
เมื่อคุณแก้ไขแล้วเสร็จ :
git commit
นี่จะ scan local repository เพื่อหาการเปลี่ยนแปลงที่ได้เกิดขึ้น และจะ “commit”การเปลี่ยนแปลงของคุณ ดังนั้นมันจะไม่ถูกเขียนทับโดยการpull
. ต่างกับ CVS โดยที่จุดนี้มัจะยังไม่ส่งไฟล์ไปยังที่ใด จริงๆ . มันคล้ายกับ local tag สำหรับ code ที่คุณปรับปรุง.
เพื่อที่จะทำให้การแก้ไขถูกรวมไว้ใน โครงสร้างต้นไม้หลัก , ให้สร้าง patchfile ดังนี้ :
git format-patch origin/master
ซึ่งจะสร้าง patch files จำนวน 1 ไฟล์หรือมากกว่า ซึุ่งสามารถส่งแบบ manual ทาง email ไปยัง mailinglist.ได้
Tips and Tricks
- ให้ทำการ pull เสมอ ก่อนเริ่มทำงานบน patches ใหม่ , เพื่อทำให้มั่นใจว่าคุณไมไ่ด้สร้าง conflict .
- Make sure your editor does not change line endings (from Unix LF to DOS CRLF), this would result in a complete file replace, instead of a small patch because each line was changed.
- Make a patch for a single feature. When you worked on two different features (eg, a language fix and a function update),
add
andcommit
two patches, with one for each feature. Using the–patch
option foradd
makes that easy for you by asking what to include in the patch. - Patches should be sent to the mailinglist and you should explain what they do and why, but we really prefer pull requests.
ฟ * A web interface to the git repository is available at http://github.com/splitbrain/dokuwiki
Mixing the official tree with own patches
explain branches
Maintaining a stable version with git
Git isn't only for DokuWiki developers, it can be used to get the latest stable version and to update to the next stable version when it is released. To do so you need to clone the repository but work in the stable branch:
git clone git://github.com/splitbrain/dokuwiki.git cd dokuwiki git checkout -b stable origin/stable
Now you can pull all needed updates whenever a new release is made:
git pull
Why Git?
The reasons for a distributed RCS are well explained at Why Darcs. So why did we switch from darcs to git?
While darcs is somewhat more intuitive to use, the differences between both systems aren't very big. Except that git is now much more often used than darcs. In addition, darcs doesn't work very well for larger projects. DokuWiki isn't shrinking and the quirks and slowness of darcs is quite a burden sometimes.
Also using a more popular revision control system makes it possible to outsource the hosting to services like github, which means less stuff to administer for us and less traffic on the DokuWiki server.
A more popular revision control system also makes it easier for new developers and other contributors to participate in the project. If they have to learn a new RCS just to start working on the code, that's a barrier to entry that they may not overcome. (It's amazing how little it takes to keep people from participating!) Smoothing the path a bit for new contributors can improve the quality of the code significantly.
You may also have a look at the following talks/videos to estimate why Git is a really useful tool: