SlideShare a Scribd company logo
How to use Git from Vim
2013/11/16 VimConf 2013
cohama / @c0hama
About me
cohama
❖ Twitter @c0hama
❖ from Nagoya
➢ Nagoya.vim
❖ vim-smartinput-endwise, theocamlspot.vim
❖ JavaScript, Ruby, OCaml, Haskell
Git / Vim ?

Messed up...
Using Git from Vim

Life changing!!
Table of Contents
1. Using Git from Vim (w/o any plugins)
2. Plugins for Git
3. Advanced usage
Table of Contents
1. Using Git from Vim (w/o any plugins)
2. Plugins for Git
3. Advanced usage
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)
Getting ready to use

$ git config --global core.editor vim
# or
$ git config --global core.editor gvim -f
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>
Editing commit message
:!git commit
Showing diff to be committed
:DiffGitCached
Editing rebase-interactive (rebase -i)
:!git rebase -i HEAD~3
Showing commit in rebase-interactive
K
Table of Contents
1. Using Git from Vim (w/o any plug-ins)
2. Plugins for Git
3. Advanced usage
vim-fugitive fundamentals
● These commands are performed in
buffer directory.
:Gwrite git-add
:Gcommit git-commit
:Git xxx any git command
:Gdiff (vim-fugitive)
● git-diff by vimdiff

dp
:diffput

index
Interactive “git add -p”

worktree
: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
gitv
● gregsexton/gitv
○ gitk clone for Vim.
○ viewing log history, change set and
refs.
○ requires vim-fugitive.
:Gitv
● showing repository’s history

log

diff
:Gitv!
● showing file’s history

log

file
Table of Contents
1. Using Git from Vim (w/o any plugins)
2. Plugins for Git
3. Advanced usage
Advanced usage of gitv and fugitive
● Remember the gitv window.
SHA-1 hash!

● Get the hash of the current line.
matchstr(getline('.'), '[zsx+ze]$')
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
Demo
Conclusion
1. It’s easy to use Git from Vim
2. vim-fugitive and gitv are wonderful.
3. Hacking gitv will change your life.

More Related Content

ODP
GIT - DUG Antwerp
ODP
Introduction to Vim 8.0
PDF
The NetBSD package Collection - a.k.a pkgsrc
PDF
BKK16-403 Android HAL Consolidation Status
ODP
Not so brief history of Linux Containers
ODP
What's missing from upstream kernel containers?
PDF
Let's Count Bytes! Launching Ruby in 32K of RAM
PDF
nebulaconf
GIT - DUG Antwerp
Introduction to Vim 8.0
The NetBSD package Collection - a.k.a pkgsrc
BKK16-403 Android HAL Consolidation Status
Not so brief history of Linux Containers
What's missing from upstream kernel containers?
Let's Count Bytes! Launching Ruby in 32K of RAM
nebulaconf

What's hot (19)

ODP
Git.odp 0
PDF
C from FW
PDF
MazuV-Debug-System
PDF
BKK16-307 LHG OE Initiative
PDF
KDE Plasma Develop Intro
PDF
LCA13: KVM for Core, LEG and LNG
PDF
ekbpy'2012 - Антон Патрушев - ZeroMQ
PDF
نگاهی به Gtk3
PPTX
MeteorJS - How to start
PDF
BKK16-102 Creating new workload for Workload Automation & using WA with LAVA
PDF
LSK 13.07
KEY
ひけらかし会:辞書式圧縮
PDF
pkgsrc 2013 - the record of the past year
PDF
Cloud-Native: A New Ecosystem for Putting Containers into Production
PDF
Creare Docker da zero con GoLang - Giulio De Donato
PDF
Mastering in troubleshooting nfv
PDF
How Docker didn't invent containers (Docker Meetup Brno #1)
PPTX
Central Iowa Linux Users Group October Meeting: Centos 8
PDF
"Developing a multicurrency, multisignature wallet" by Alex Melville
Git.odp 0
C from FW
MazuV-Debug-System
BKK16-307 LHG OE Initiative
KDE Plasma Develop Intro
LCA13: KVM for Core, LEG and LNG
ekbpy'2012 - Антон Патрушев - ZeroMQ
نگاهی به Gtk3
MeteorJS - How to start
BKK16-102 Creating new workload for Workload Automation & using WA with LAVA
LSK 13.07
ひけらかし会:辞書式圧縮
pkgsrc 2013 - the record of the past year
Cloud-Native: A New Ecosystem for Putting Containers into Production
Creare Docker da zero con GoLang - Giulio De Donato
Mastering in troubleshooting nfv
How Docker didn't invent containers (Docker Meetup Brno #1)
Central Iowa Linux Users Group October Meeting: Centos 8
"Developing a multicurrency, multisignature wallet" by Alex Melville
Ad

Similar to How to use git from vim @vim conf2013 (20)

PDF
Useful Vim Plugins
PDF
Advanced Git Tutorial
PDF
Git in Eclipse
PPTX
Git kelvin
PDF
Git and Github
PPTX
Crash course in git and github
ODP
How to write patches for Vim
PPTX
Git from the trenches
PDF
You're doing it wrong! Git it right!
PDF
Git for Beginners
PPTX
PDF
Git and Github workshop
PDF
Git Init (Introduction to Git)
PPTX
Git: Why And How to
PPTX
Open source
ODP
Git presentation
PDF
Improving your workflow with git
PDF
PPTX
Git and git workflow best practice
ODP
How to use git without rage
Useful Vim Plugins
Advanced Git Tutorial
Git in Eclipse
Git kelvin
Git and Github
Crash course in git and github
How to write patches for Vim
Git from the trenches
You're doing it wrong! Git it right!
Git for Beginners
Git and Github workshop
Git Init (Introduction to Git)
Git: Why And How to
Open source
Git presentation
Improving your workflow with git
Git and git workflow best practice
How to use git without rage
Ad

More from cohama (8)

PDF
Vim の話
PPTX
2016 04-15 nl-nagoya_vim8
PPTX
2015 12-04 about_neovim
PPTX
2014 12-06 ngk2014-b_2014年のvim
PDF
Auto closing parenthesis @vim conf2014
PDF
(初心者向け) Vim の機能紹介@nagoya.vim #1
PDF
Vim script と vimrc の正しい書き方@nagoya.vim #1
PDF
すごいVimでhaskellを書こう@なごやまつり
Vim の話
2016 04-15 nl-nagoya_vim8
2015 12-04 about_neovim
2014 12-06 ngk2014-b_2014年のvim
Auto closing parenthesis @vim conf2014
(初心者向け) Vim の機能紹介@nagoya.vim #1
Vim script と vimrc の正しい書き方@nagoya.vim #1
すごいVimでhaskellを書こう@なごやまつり

Recently uploaded (20)

PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
Teaching material agriculture food technology
PDF
Approach and Philosophy of On baking technology
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Spectroscopy.pptx food analysis technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Electronic commerce courselecture one. Pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Big Data Technologies - Introduction.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation_ Review paper, used for researhc scholars
Diabetes mellitus diagnosis method based random forest with bat algorithm
Teaching material agriculture food technology
Approach and Philosophy of On baking technology
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Review of recent advances in non-invasive hemoglobin estimation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
sap open course for s4hana steps from ECC to s4
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Spectroscopy.pptx food analysis technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Electronic commerce courselecture one. Pdf

How to use git from vim @vim conf2013