優雅的在 emacs 中使用 git
TRANSCRIPT
![Page 1: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/1.jpg)
優雅的在 Emacs 中使⽤用 git
Cosucp 2013Superbil (鄭開元)
![Page 2: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/2.jpg)
About Me•軟體⼯工程師、iOS 開發
•Emacs 使⽤用經驗⼤大約 1 年
•Git 使⽤用經驗⼤大約 4 年
•PyHUG 主持⼈人
•about.me/superbil
• freenode #emacs.tw #g0v.tw #python.tw on ircCloud
![Page 3: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/3.jpg)
Outline
• What is Emacs ?
• What is Git ?
• Magit
• Live Demo
![Page 4: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/4.jpg)
什麼是 Emacs ?
![Page 5: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/5.jpg)
編輯器
![Page 6: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/6.jpg)
Why I use Emacs?
• Magit
• Org-mode
• eshell
• ansi-termrun zshell
![Page 7: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/7.jpg)
Emacs 基本介紹
• Ctrl + h t // emacs tutorial
• Ctrl + {b,n,p,f} // h j k l
• Ctrl + x b // 切換 buffer
• Ctrl + x Ctrl + e // 執⾏行 ( ) 中的 elisp
• Ctrl + h m // 查詢當下 mode 的⽂文件
![Page 8: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/8.jpg)
Emacs 的熱鍵很難按
![Page 9: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/9.jpg)
更換你的 Ctrl 鍵位置
• Caps Lock 其實⼀一點都不重要
• Ctrl 在下⾯面的位置其實是⾮非常難按的
巨⼈人出現了阿!!!
![Page 10: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/10.jpg)
Emacs in better than X !
政治正確
![Page 11: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/11.jpg)
為何不同時使⽤用Emacs 和 Vim ?
by 程序员时髦值指南
同时⽤用 Vim 和 Emacs,这⼈人早被烧死了
![Page 12: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/12.jpg)
什麼是
![Page 13: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/13.jpg)
什麼是 Git ?
• Git 是版本控管系統
• 管理程式碼、⽂文件資源、法規(?)
• Git 是分散式的,內容都在本地端
• Git 很快
![Page 14: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/14.jpg)
Git 更新流程
![Page 15: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/15.jpg)
base command for git• status
顯⽰示狀態
• push
把本地推去雲端
• pull
抓雲端資料下來
• add
新增檔案到 stash
• commit把⺫⽬目前狀態寫⼊入log
• log
歷史記錄
• rebase
重寫歷史記錄
![Page 16: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/16.jpg)
新增到 staging area 時,選擇要的區塊
可以以⾏行為單位,⽽而不是以檔案每⼀一次的 commit log 更加乾淨
git add --patch
![Page 17: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/17.jpg)
Magitbest way use git in Emacs
![Page 18: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/18.jpg)
What is Magit ?
• git GUI on Emacs
• that's is very good for keyboard fans
![Page 19: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/19.jpg)
Different with vc
• VC
• 使⽤用相同的熱鍵和使⽤用 SCMgit, svn, etc...
• Magit
• 從 Git 的⾏行為來提供使⽤用者介⾯面
![Page 20: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/20.jpg)
Magit 介⾯面簡介
![Page 21: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/21.jpg)
Show Sections
![Page 22: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/22.jpg)
Magit commit 介⾯面
![Page 23: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/23.jpg)
History
![Page 24: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/24.jpg)
Write changelog
![Page 25: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/25.jpg)
Live Demo
![Page 26: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/26.jpg)
Oops... Magit 沒⽀支援的功能
• M-x magit-git-command
• hotkey is ‘:’ <your action>
• this will run `git --no-pager <your action>`
![Page 27: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/27.jpg)
Some useful mode
• org-magitlink to magit-statususe '~/project/kuansim/::status'
![Page 28: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/28.jpg)
Q & A
![Page 29: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/29.jpg)
Learn more about Magit
• Emacs: magit-mode Tutorial
• EmacsWiki: Magit
• Magit User Manual
![Page 30: 優雅的在 Emacs 中使用 git](https://reader035.vdocuments.mx/reader035/viewer/2022081717/5554ad00b4c90502618b5346/html5/thumbnails/30.jpg)
Thank you