How to use git from vim @vim conf2013

3,240 views
2,971 views

Published on

Published in: Technology, Art & Photos
0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,240
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
33
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide

How to use git from vim @vim conf2013

  1. 1. How to use Git from Vim 2013/11/16 VimConf 2013 cohama / @c0hama
  2. 2. About me cohama ❖ Twitter @c0hama ❖ from Nagoya ➢ Nagoya.vim ❖ vim-smartinput-endwise, theocamlspot.vim ❖ JavaScript, Ruby, OCaml, Haskell
  3. 3. Git / Vim ? Messed up...
  4. 4. Using Git from Vim Life changing!!
  5. 5. Table of Contents 1. Using Git from Vim (w/o any plugins) 2. Plugins for Git 3. Advanced usage
  6. 6. Table of Contents 1. Using Git from Vim (w/o any plugins) 2. Plugins for Git 3. Advanced usage
  7. 7. Using Git from Vim w/o any plugins ● At first, use Git from default Vim! ● Why? ○ learn about natural Vim power. ○ too many plug-ins is too complex. ○ forbidden to access github.com. (It’ me)
  8. 8. Getting ready to use $ git config --global core.editor vim # or $ git config --global core.editor gvim -f
  9. 9. Using Git from command-line mode ● Just use :! :!git add % :!git commit -m”commit message” :!git checkout HEAD % ● Define key mapping (if you need) “ e.g. nnoremap ga :<C-u>!git add %<CR>
  10. 10. Editing commit message :!git commit
  11. 11. Showing diff to be committed :DiffGitCached
  12. 12. Editing rebase-interactive (rebase -i) :!git rebase -i HEAD~3
  13. 13. Showing commit in rebase-interactive K
  14. 14. Table of Contents 1. Using Git from Vim (w/o any plug-ins) 2. Plugins for Git 3. Advanced usage
  15. 15. vim-fugitive fundamentals ● These commands are performed in buffer directory. :Gwrite git-add :Gcommit git-commit :Git xxx any git command
  16. 16. :Gdiff (vim-fugitive) ● git-diff by vimdiff dp :diffput index Interactive “git add -p” worktree
  17. 17. :Gstatus (vim-fugitive) ● git-status output as a new window. <C-n> next file <C-p> prev file <CR> edit file add/reset cc commit D diff
  18. 18. gitv ● gregsexton/gitv ○ gitk clone for Vim. ○ viewing log history, change set and refs. ○ requires vim-fugitive.
  19. 19. :Gitv ● showing repository’s history log diff
  20. 20. :Gitv! ● showing file’s history log file
  21. 21. Table of Contents 1. Using Git from Vim (w/o any plugins) 2. Plugins for Git 3. Advanced usage
  22. 22. Advanced usage of gitv and fugitive ● Remember the gitv window. SHA-1 hash! ● Get the hash of the current line. matchstr(getline('.'), '[zsx+ze]$')
  23. 23. Advanced usage of gitv and fugitive ● Use :Git with the hash. :Git rebase <hash> :Git reset --hard <hash> :Git checkout -b hoge <hash> …more ● Define key mappings
  24. 24. Demo
  25. 25. Conclusion 1. It’s easy to use Git from Vim 2. vim-fugitive and gitv are wonderful. 3. Hacking gitv will change your life.

×