GitHub - tpope/vim-fugitive: fugitive.vim: a Git wrapper so awesome, it should b...
source link: https://github.com/tpope/vim-fugitive
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
fugitive.vim
Fugitive is the premier Vim plugin for Git. Or maybe it's the premier Git plugin for Vim? Either way, it's "so awesome, it should be illegal". That's why it's called Fugitive.
The crown jewel of Fugitive is :Git
(or just :G
), which calls any
arbitrary Git command. If you know how to use Git at the command line, you
know how to use :Git
. It's vaguely akin to :!git
but with numerous
improvements:
- The default behavior is to directly echo the command's output. Quiet
commands like
:Git add
avoid the dreaded "Press ENTER or type command to continue" prompt. :Git commit
,:Git rebase -i
, and other commands that invoke an editor do their editing in the current Vim instance.:Git diff
,:Git log
, and other verbose, paginated commands have their output loaded into a temporary buffer. Force this behavior for any command with:Git --paginate
or:Git -p
.:Git blame
uses a temporary buffer with maps for additional triage. Press enter on a line to view the commit where the line changed, org?
to see other available maps. Omit the filename argument and the currently edited file will be blamed in a vertical, scroll-bound split.:Git mergetool
and:Git difftool
load their changesets into the quickfix list.- Called with no arguments,
:Git
opens a summary window with dirty files and unpushed and unpulled commits. Pressg?
to bring up a list of maps for numerous operations including diffing, staging, committing, rebasing, and stashing. (This is the successor to the old:Gstatus
.) - This command (along with all other commands) always uses the current buffer's repository, so you don't need to worry about the current working directory.
Additional commands are provided for higher level operations:
- View any blob, tree, commit, or tag in the repository with
:Gedit
(and:Gsplit
, etc.). For example,:Gedit HEAD~3:%
loads the current file as it existed 3 commits ago. :Gdiffsplit
(or:Gvdiffsplit
) brings up the staged version of the file side by side with the working tree version. Use Vim's diff handling capabilities to apply changes to the staged version, and write that buffer to stage the changes. You can also give an arbitrary:Gedit
argument to diff against older versions of the file.:Gread
is a variant ofgit checkout -- filename
that operates on the buffer rather than the file itself. This means you can useu
to undo it and you never get any warnings about the file changing outside Vim.:Gwrite
writes to both the work tree and index versions of a file, making it likegit add
when called from a work tree file and likegit checkout
when called from the index or a blob in history.:Ggrep
is:grep
forgit grep
.:Glgrep
is:lgrep
for the same.:GMove
does agit mv
on the current file and changes the buffer name to match.:GRename
does the same with a destination filename relative to the current file's directory.:GDelete
does agit rm
on the current file and simultaneously deletes the buffer.:GRemove
does the same but leaves the (now empty) buffer open.:GBrowse
to open the current file on the web front-end of your favorite hosting provider, with optional line range (try it in visual mode). Plugins are available for popular providers such as GitHub, GitLab, Bitbucket, Gitee, Pagure, Phabricator, Azure DevOps, and sourcehut.
Add %{FugitiveStatusline()}
to 'statusline'
to get an indicator
with the current branch in your statusline.
For more information, see :help fugitive
.
Screencasts
Installation
Install using your favorite package manager, or use Vim's built-in package support:
mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/fugitive.git
vim -u NONE -c "helptags fugitive/doc" -c q
What happened to the dispatch.vim backed asynchronous
:Gpush
and:Gfetch
?
This behavior was divisive, confusing, and complicated inputting passwords, so
it was removed. Use :Git! push
to use Fugitive's own asynchronous
execution, or retroactively make :Git push
asynchronous by pressing
CTRL-D
.
Why am I getting
core.worktree is required when using an external Git dir
?
Git generally sets core.worktree
for you automatically when necessary, but
if you're doing something weird, or using a third-party tool that does
something weird, you may need to set it manually:
git config core.worktree "$PWD"
This may be necessary even when simple git
commands seem to work fine
without it.
So I have a symlink and...
Stop. Just stop. If Git won't deal with your symlink, then Fugitive won't either. Consider using a plugin that resolves symlinks, or even better, using fewer symlinks.
Self-Promotion
Like fugitive.vim? Follow the repository on GitHub and vote for it on vim.org. And if you're feeling especially charitable, follow tpope on Twitter and GitHub.
License
Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
See :help license
.
Recommend
-
186
pathogen.vim Manage your 'runtimepath' with ease. In practical terms, pathogen.vim makes it super easy to install plugins and runtime files in their own private directories. For new users, I recommend using Vi...
-
175
vim-prettier A vim plugin wrapper for prettier, pre-configured with custom default prettier settings. NOTE: If you want to fallback to older version of prettier/vim-prettier please add this to your .vi...
-
206
Files Permalink Latest commit message Commit time...
-
158
rails.vim This is a massive (in a good way) Vim plugin for editing Ruby on Rails applications. Easy navigation of the Rails directory structure. gf considers context and knows about partials, fixtures, and m...
-
125
commentary.vim Comment stuff out. Use gcc to comment out a line (takes a count), gc to comment out the target of a motion (for example, gcap to comment out a paragraph), gc in visual mo...
-
204
Vim Markdown runtime files This is the development version of Vim's included syntax highlighting and filetype plugins for Markdown. Generally you don't need to install these if you are running a recent version of Vim. If you want...
-
86
vim-cucumber - Vim Cucumber runtime files
-
5
zoxide.vim A small (Neo)Vim wrapper for zoxide Requirements A recent version of Vim or Neovim The zoxid...
-
3
vim-sexp mappings for regular people I'm really liking my first impressions of vim-sexp. It's like paredit minus a couple of parts of paredit that are impossibly tricky to implement in...
-
5
Vim Diagon Vim wrapper of Diagon API to generate simple Unicode or ASCII diagrams Table of Contents Prerequisites Diagon's command line interface is required for this plugin to work. sudo sna...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK