My expectations from a git plugin were rather simple.
- Display the active git branch of current file.
- Switch between different branches, without quitting Vim.
- Multi-platform support.
git-branch-info.vim
This plugin was designed to display the current branch info in the vim status line.
set laststatus=2 " Enables the status line at the bottom of Vim
set statusline=%{GitBranchInfoString()}
In addition to the current branch info, it can also list all the branches in the current git repo through a menu (only in gVim) and allows to checkout/fetch a particular branch.
One caveat of this plugin is it's designed with a Linux user in mind and it didn't work in windows in its original form. Since it was project hosted on Github, I decided to fork it and make a windows version of the plugin. The windows version can be downloaded from the project's windows fork.
git.vim
Git.vim is a more comprehensive plugin that allows the user to perform a lot more Git operations from within the Vim environment. The github home page for this plugin has a list of all the functionalities available through this plugin.
The name of the function called to set the status line is GitBranch(). So the lines added to .vimrc will be,
set laststatus=2
set statusline=%{GitBranch()}
But unfortunately there is a bug in the GitBranch() function. Once again Github to the rescue, the project is forked and the bug fixed fork can be downloaded here. A pull request is submitted to the author to fix this bug.
Some of the other features of this plugin are showcased below. This plugin comes with syntax files that hightlights the git log, git diff and git commit messages. The syntax highlighting can be seen in the screenshots shown below.
GitCommit
:GitCommit opens a split window to enter the log message and commits the current file to the repository. If no files are staged to the index, it will automatically use git commit -a option to stage all the changed files and commit them to the repository.
GitDiff
:GitDiff opens a split window with the output of the git diff command on the current file.
GitLog
:GitLog to show the commit log of the current file.
GitBlame
:GitBlame Shows the changes made to a file on a line-by-line basis, by displaying the name of the user next to each line in a vertical split.
There is an experimental feature for merging files with conflicts using Vimdiff :GitVimDiffMerge and any other git command can be called from Vim by issuing :Git








