Code Monkey home page Code Monkey logo

vim-fugitive's Introduction

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, or g? 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. Press g? 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 of git checkout -- filename that operates on the buffer rather than the file itself. This means you can use u 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 like git add when called from a work tree file and like git checkout when called from the index or a blob in history.
  • :Ggrep is :grep for git grep. :Glgrep is :lgrep for the same.
  • :GMove does a git 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 a git 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

FAQ

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.

vim-fugitive's People

Contributors

blueyed avatar bobrippling avatar cedarbaum avatar elyscape avatar flatcap avatar guns avatar idbrii avatar jsit avatar linuxsuren avatar living180 avatar manicmaniac avatar mcepl avatar mikl avatar mrdubya avatar natebosch avatar odnoletkov avatar osandov avatar pappasam avatar patrickdavey avatar pavoljuhas avatar qstrahl avatar rbong avatar runiq avatar ryosusami avatar teoljungberg avatar tmhedberg avatar tommcdo avatar tpope avatar tranquility avatar yut23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-fugitive's Issues

Commands not available in new tabs

The fugitive commands are not available for new tabs in vim (happens both in MacVim and the OSX vim). The plugin is loaded in all tabs and continues to work in the first tab, though.

Pull/Push in background

Using :Git pull/push origin master takes away the entire screen for a considerable amount of time. I suggest running pull/push in background and display output when done using quickfix window.

preview diff

Hi, I've googled around on how to use fugitive and also read the help file, but I can't find a way that is efficient to preview the changes before staging a file.

I do a D on the file to be staged (after Gstatus) and then my cursor is moved to the diff window then I need a bunch of hacky tricks to close those split diff windows just to get back to where I was in the Gstatus window. How is this efficient ? Or what am I doing wrong ?

Thanks

Feature Request: Simple Status

Hi,

I love using vim-fugitive, it has really change my workflow. Anyhow, this is feature request. If you don't agree with it, feel free to reject, I just thought it would make a nice addition:

If you do a :Gstatus and no changes have been made, I propose that instead of opening up a split just to display the 'no changes have been made' message should be replaced by a simple vim status line saying the same. This way, it wouldn't force the developer to close the split, and would be quicker.

Map :Git commit to :Gcommit

I find myself accidentally entering :Git commit instead of :Gcommit sometimes. This doesn't work since Vim can't handle the output git is giving it. Is there a way to alias :Git commit to actually execute :Gcommit? Thanks.

Ggrep output too long

Is there a way to scroll through the output of a long result list of a :Ggrep command?

Current directory gets changed

Hi,

I noticed that fugitive changes the current directory after loading a file. For example, I usually stay in the root of my project/repository directory and then open files in subdirectories without changing into them. This way I can call make from the top-level directory and other things. But with fugitive opening a file in a subdirectory cds into the directory the file is in, which interferes with that usage pattern. Is it possible to restory the directory after fugitive did its thing?

Pre-commit hooks and :Gcommit

I have a pre-commit hook which calls a script to run all the unit-tests for the app in the repository.

When trying to :Gcommit, I only get a:
fugitive: n files found

The split commit window doesn't appear at all. :Git commit displays a screen showing the tests running and then the text asking for a commit message after the tests are done. Pressing anything displays gibberish and I have to CTRL-C to get out of that screen. Removing the hook "fixes" the problem.

Running git commit on the shell works, with or without the hook.

:Gblame overwrites lcd

After setting lcd, using :Gblame will lcd to the root of the repo, and will not restore the previous working directory

Duplicate "Signed-off-by" lines when using :Gcommit -s

I'm seeing duplicate "Signed-off-by" lines in my commits when I use :Gcommit -s

While editing the commit message I see the "Signed-off-by" line once, but when inspecting the actual commit object that gets added to the repository I'm seeing it twice.

My tired eyes can't grok the code at this hour, but I'm guessing that the cause is the same as I reported in this ticket against git-vim:

http://github.com/motemen/git-vim/issues#issue/8

And a fix similar to the one I proposed for that will probably work here too:

http://github.com/wincent/git-vim/commit/fc3ad49663e92ecabf1246a8ce33031fbcab49fa

vim hangs after fugitive command launched

When trying any fugitive command (mostly tried with :Gstatus and :Gdiff), vim just hangs. Nothing happens and I need to do ctrl-z and kill -9 to unblock the operation. That is on my laptop, using Git 1.7.4.1 and Vim 7.3

Tried the same thing on a different server with git 1.5.6.5 and vim 7.1 and everything works as it should.

In both cases, I'm using a "clean" vim setup (no .vimrc, no plugins other than fugitive) and testing using fugitive git repository.

Is this related to git 1.7? How can I see what's going on? I'd like some pointers on how to debug this. I saw some issues somewhat like that on stackoverflow, but they were related to using msysgit, while I'm on Debian.

Gdiff and autocommand

First of all thanks for a great plugin!
Not very sure this is related to fugitive but here it goes...
I am trying to have an autocommand that will unfold all my folds after Gdiff
is called and then also set the foldmethod to diff to fix the display. I tried it
like that which I think should work but...

function OpenFoldsAndDiff()
if &diff
foldopen
set foldmethod=diff
endif
endfunction

au FilterWritePost * if &diff |set foldmethod=marker| endif
au FilterWritePre * call OpenFoldsAndDiff()

D.

fugitive interferes with DirDiff plugin

If used with fugitive, DirDiff windows get messed up during use (jump to at least one other file diff). I think this is because without fugitive, doing :bd! on a left diff window jumps to the right diff window. With fugitve, it jumps to the window below, breaking Vim's normal cursor jump flow. This interferes with DirDiff's reasonable assumptions and breaks that plugin.

Not using the current directory

First of all: Really amazing plugin! Thank you for for that!

I've just discovered a little bug:

  1. I startet vim,
  2. changed the working directory
  3. and called ":Git pull"

Git pull resists in the previos directory.

git push origin requiring password

hi, I'm trying a ":Git push origin" (to a remote repo) from within MacVim after a ":Gedit", ":Gwrite", and ":Gcommit" but the plugin hangs after asking for a password.

Running "git push origin" from the command line correctly receives the password input and updates the remote repo. Sure it's simple enough to use the command line, but is there a way to pass the password to the git prompt with vim? I don't want to set up an ssh key for this project.

-A

Gcommit fails

When trying to do :Gcommit, I end up with an error:

fugitive: fatal: There was a problem with the editor false.

Tested on head version ( 762bfa7 )

Need to set --work-tree?

I'm having some issues with running fugitive.vim under windows with msysgit. Running Gstatus tells me that all the files in the repo are marked as deleted. After researching the issue, it looks like --work-tree may need to get set as well. I'm surprised that no one has run into this before...

"d" to diff from Gstatus and/or as generic mapping for file objects

I think just using "d" on a path / file in "Gstatus" would be useful, just like "o" is available (via the generic mappings).

"d" might become a special case here similar to "-" and "p", which are only mapped in Gstatus AFAIK.

I've just started using fugitive and am still at the beginning of learning vim properly, so I might miss something here.

Apart from that, thanks a lot for a great plugin!

problem with "vim file"

When I try to open a file with vim (with "vim my_file", not ":e my_file"), I have this error :

".git/COMMIT_EDITMSG" 4L, 151C
Error detected while processing function <SNR>20_buffer..<SNR>20_throw:
line    2:
E605: Exception not caught: fugitive: not a git repository: /home/vallet_e/dev/t
ask_manager/.git/COMMIT_EDITMSG
Error detected while processing function <SNR>20_buffer:
line    4:
E171: Missing :endif
Error detected while processing function <SNR>20_Detect:
line    8:
E171: Missing :endif

This example is the result of a "git commit" :-(

Empty :Gstatus window on Mac

Hi, with the latest[*] version of fugitive, whenever I try using :Gstatus, I get an empty fugitive window, although there are changes in the working tree. I'm using the latest MacVim, but the problem occurs on the default vim7.2. My primary shell is zsh, but the problem also occurs in bash.

Just checked, I see this issue with fugitive 1.0, as well.

Enable keychain when invoking :Git push

Hi,

I'm not sure if this is even possible, but who knows :) When I commit some changes and try to push them into a remote I recieve an error telling me the host rejected me due to key verification failiure. Obviously the keychain is not present in vimconsole (or whatever starts the git command). Would it be possible to fix that?

conflict with DirDiff plugin

When vim-fugitive and DirDiff are both installed every time you open/select a file diff from the DirDiffs results window it creates an extra copy of the results window. Additionally the diff and results windows fail to resize.

GDiff produces errors on windows

This is using gvim 7.2 on windows xp with msysgit 1.7.0.2 (+ this patch: http://code.google.com/p/msysgit/issues/detail?id=428)

Most of the functions of fugitive.vim work fine. However, when I open a file in my repository and make some changes and then do :GDiff, I get the following error:

Error detected while processing function 11_BufReadIndexFile..11_ReplaceCmd:
line 26:
E302: Could not rename swap file

I also tried doing :GStatus and then pressing 'D' on a file with changes. This produces two errors, the above and the following:

Error detected while processing function 11_StageDiff: line 13: E171: Missing :endif

Additionally, after this error message, the open file will have changed to fugitive:\\path\to\repo\.git\\0\filename.c. I've checked with process explorer, and as far as I can see, vim is the only application with a handle to the swap files and I am the admin on this machine, so that shouldn't be a problem either.

REQUEST: statusline command handling of an error

I tried using %{fugitive#statusline()} in statusline, but when I open a file that is not under Git version control. The command issues an error. It would be helpful if a file is not under the version control, it says "Not in Git" or something. Or it could simply suppress the warning.

enhanced git log/diff feature request

Hello,

First of all, thanks for this awesome plugin!

There's one thing that I find missing in it for it to be supazomggreat tho, the ability to browse your git tree like gitk does.

I think of something pretty simple: some command, like :Gitk, which would display git log --graph --oneline --all in a :split window. When you select one of the commit, another window appear with the list of modified files of that commit. Finally, when you select one of the file, a vimdiff window shows what was modified.

I think you probably can rip most of the Gundo plugin, which does pretty much that: visualize file differences along a timeline.

As this plugin is pretty file-centric, maybe we could start by a simple :Ghistory which would create a split with the commits concerning that file, and when you move over them it shows a vimdiff below. This would allow to enhance with stuffs like "revert to this commit", etc.

Tell me what you think :)

:Gcommit not editing .git\COMMIT_EDITMSG on windows

When I run :Gcommit it tries to add the file ..gitCOMMIT_EDITMSG to the root dir instead of editing my ..git\COMMIT_EDITMSG like it should.

Steps to reproduce:

  • Edit a file in a local repo
  • Make some changes
  • :w
  • :Gcommit
  • Edit message
  • :wq
  • Notice ..gitCOMMIT_EDITMSG instead of ..git\COMMIT_EDITMSG

I'm using:

  • Vim72 (compiled August 5 2010)
  • MS-Windows 32-bit GUI version
  • Windows XP SP3
  • Msys GIT/TortoiseGIT

Staging changes to submodule in :Gstatus window doesn't work

When trying to stage changes to a submodule it looks as though fugitive tries to stage the entire line instead of just the file/path name.

The line in the window containing information about the submodule:
# modified: submodulepath (new commits)

The error message:
fatal: pathspec 'submodulepath (new commits)' did not match any files

Using affce71

vim-fugitive causes current MacVim snapshot to hang

When doing :Gstatus and hitting '-' to add a file it just hangs

Not sure what the cause is, but it requires killing MacVIM forcibly.

Does not occur in the terminal version of vim that ships with Mac OS X.

How will it work?

I put fugitive.vim in ~/.vim/plugin but I have none of the commands available (as mentioned in the doc).

Quickfix window is a hot mess

Ggrep, Glog, any of the fugitive stuff that should be using the quickfix window doesn't seem to load the window properly.

Glog for example just pushes text up from the bottom of the screen. It isn't really in a window that I can navigate up and down through. I can't seem to pick a file from the stuff that does come up, it seems to open one at random, or maybe the first file, I can't tell really.

There's also a strong possibility that I'm not doing this right. I'm a vim-newb.

trouble when using "autocmd BufEnter * cd %:p:h" in ~/.vimrc

I've got this line in my ~/.vimrc:
autocmd BufEnter * cd %:p:h

Which cd's into the directory of the file I've just opened, quite useful.
However, this seems to break most of fugitive.vim's commands, spitting out the following error message:
Error detected while processing BufEnter Auto commands for '*': E472: Command failed.

Any idea for a workaround?
I would like to use fugitive, but keep my "cd to folder" thing ;)

A noob question, exiting out of Gdiff

Love this plugin, but one thing I can't figure out is how to stop doing a Diff. If I use:
:Gdiff
It will split my windows out and let me do that, but how to do I exit that. I've tried:
:diffoff
But that doesn't get me back to my original file and remove the other "orig" version. Any tips? Thanks.

Marc

configuration of string returned by fugitive#statusline()

I wonder if it it possible to add option to configure string returned by fugitive#statusline function - so one could fit this string to his/her needs (for example return only branch name). That is not the most important thing, but would be really nice.

remove untracked file / folder

When I am in Gstatus, is there a way to delete an untracked file/folder? :Gremove is only for files tracked by git, as far as I see it. If there is no way, this is definitively a feature request. If there is, I would appreciate if you could put it in the docs :)

Thanks for this awesome git wrapper!

fugitive.vim not working for me

I've installed fugitive.vim in my /.vim/plugin directory and i'm using vim 7.2 for mac
--(saurabhve@sa-mac-saurabh)-(
)--
--(0)> vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jul 13 2009 22:28:10)
Included patches: 1-108

--(saurabhve@sa-mac-saurabh)-(~)--
--(1)> vim
Error detected while processing /Users/saurabhve/.vim/plugin/fugitive.vim:
line 1:
E477: No ! allowed:
line 2:
E488: Trailing characters:
line 3:
E488: Trailing characters:
line 4:
E488: Trailing characters:
line 5:
E488: Trailing characters: <meta http-equiv=
line 6:
E488: Trailing characters: <title>plugin/fugitive.vim at master from tpope/vim-fugitive - GitHub</title>
line 7:
E488: Trailing characters: <link rel=
line 8:
E488: Trailing characters: <link rel=
line 10:
E488: Trailing characters: <link href=
line 11:
E488: Trailing characters: <link href=
line 14:
E488: Trailing characters: <script type=
line 15:
E121: Undefined variable: typeof
E15: Invalid expression: (typeof console == "undefined" || typeof console.log == "undefined")
line 2883:
E171: Missing :endif

:Glog fouls up current buffer

Note: installed version is a8bd148 I have also tested with
45fe471 and get the same behaviour.

$ vim somefile-under-git
:Glog

After returning to the buffer, the o and O commands no longer work. :map o and :map O report the following:
n o *@:exe 17_GF("split")
n O *@:exe 17_GF("tabedit")

It also reports that modifiable has been set, whenever I attempt to edit the current buffer. Haven't noticed any other oddities but, ahem... ;)

See whitespace errors during patching

In a normal terminal with color turned on, staging files using "git add ---interactive" shows whitespace errors using syntax coloring, which greatly helps to avoid accidentally staging hunks with damaged whitespace.

Is there any away we could get some sort of visual indication when staging patches from inside Vim with :Gstatus and "p"? Or are we forever consigned to uncolored text because we're effectively shelling out to an external process?

Pull/Push in background

Using :Git pull/push origin master takes away the entire screen for a considerable amount of time. I suggest running pull/push in background and display output when done using quickfix window.

Diff windows interfere with nowrap.

After closing a window opened with :Gdiff, all windows get wrap set even if they were nowrap before.

Steps to reproduce:
vi somefile # local file in the repo
set wrap
:vnew newfile
setlocal nowrap
iabc
1000. " long line, no wrapping
l
:Gdiff
h
:wq
At this point newfile has wrap set where it didn't before.

Using version 24c5a45

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.