19

Short Answer Just use the normal interactive buttons. In (regular) vim, pressing p drops you into the interactive terminal patch, so it's the interface you're used to. For neovim users: Just enter insert mode (i), then it works as a terminal, the cursor goes to 'stage this hunk...' line. In newer versions, you can use P instead, and the interface is builtin (...


18

There might be other ways, but this approach lets you to do more than adding a chunk, which is why I tend to use it quite a lot. Run :Gdiff command. It will open a split with version of current file that's currently in the index to the left/top of the original window. While in original window (right or bottom one), perform visual selection of changes you'd ...


13

To culminate the answers here are the ways to accomplish this: Vanilla Terminal Vim Press CTRL-Z in normal mode will drop you back in to the shell and suspend Vim. After executing your git checkout [branchname] type the fg command to return to the suspended Vim which will also force Vim to refresh. It is also noteworthy that the :checktime command in Vim can ...


13

Use the vim-merginal plugin (fugitive extension). It offers interactive TUI for: Viewing the list of branches Checking out branches from that list Creating new branches Deleting branches Merging branches Rebasing branches Solving merge conflicts Interacting with remotes(pulling, pushing, fetching, tracking) Diffing against other branches Renaming branches ...


9

As suggested by Christian Brabandt in the comments, this was caused by the 'cursorbind' setting. :help 'cursorbind': When this option is set, as the cursor in the current window moves other cursorbound windows (windows that also have this option set) move their cursors to the corresponding line and column. This option is useful for viewing the ...


8

Here's another way to do it, all within fugitive. I believe some of this is new with the 3.0 release on Aug 20, 2019. Someone had created a "What's New?" video, which I sadly can't find now. The :Gstatus command received a lot of attention. In the :Gstatus window, you can use these subcommands. There are many others, but these serve me well. <C-N> or ...


8

Vimcasts has a great series on Fugitive.vim. The episode Fugitive.vim - working with the git index would be the the most helpful for your question. You can use :Gdiff to stage only portions of a file. Running :Gdiff will show you the current file "diff-ed" with the stage/index. You can simply use Vim's diff commands (dp, do, :diffput, and :diffget) to move ...


8

I think the most likely culprit is another buffer still in diff-mode. This can happen if you're looking at multiple diffs, one after another, and don't turn off diff-mode between diffs. Disable diff-mode in irrelevant buffers The solution is to find the offending buffer(s) and turn off diff-mode with :diffoff. If you don't want to search for it, you can ...


8

You should embrace your terminal. If you use CTRL-Z, it will background Vim (or whichever process you are currently running), then you can run any commands you want, the fg to bring the process back to the foreground: <CTRL-Z> git checkout <tab> fg


7

The fugitive Git checkout <branch> has a downside that it doesn't autocomplete the branch name. Using fzf.vim I've created this command: function! s:changebranch(branch) execute 'Git checkout' . a:branch call feedkeys("i") endfunction command! -bang Gbranch call fzf#run({ \ 'source': 'git branch -a --no-color | grep -v "^\* " ', ...


7

Stage Complete or Partial Hunks with vim-gitgutter Stage Complete Hunk <Leader>hs or :GitGutterStageHunk Stage Part of an Additions-only Hunk (since 8/2019) Visual mode {Visual}<Leader>hs :'<,'>GitGutterStageHunk ('<,'> are as always inserted for you) Range :42,45GitGutterStageHunk Stage Part of any Hunk via Preview Window (...


6

You can use the jump list to go back to your file: pressing ctrlo will bring you back to the top of the commit file and pressing it a second time will bring you back to the file you were editing. (see :h CTRL-O and :h jumplist) To open the commit in a split window :h fugitive-:Gblame tells you that you can use o when you are on the commit line. You can also ...


6

As you specifically asked about solutions that use other plugins, I'll note that you can also stage visual selections using vimagit, which is a Git plugin (based on the other editor's popular Magit plugin) centered around viewing, staging, and commiting changes. To stage a visual selection using Vimagit: Run the :Magit command to open a new buffer that ...


6

Using <c-w>T to promote a window to a new tab. nnoremap <Leader>gs :Gstatus<cr><c-w>T For more help see :h CTRL-W_T


5

I'll just quote from the official plugin FAQ: FAQ Q: I installed the plugin and started Vim. Why don't any of the commands exist? A: Fugitive cares about the current file, not the current working directory. Edit a file from the repository. Q: I opened a new tab. Why don't any of the commands exist? A: Fugitive cares about the ...


5

The Gedit command is here for you. It takes an argument which is the revision you want to use, using the same logic as git-rev-parse (meaning you can use it without argument to get back to your working copy), so, on your file, type :Gedit And you're back to your working copy. References: :h fugitive-:Gedit :h fugitive-revision


5

let command in vimL allows you to assign a value to a variable. A variable may be a environment variable, or a register or an option. :let $MYVIMRC=value This command sets the value to $MYVIMRC. You can put this in .vimrc. Example: :let $MYVIMRC=C:\Users\acer\Desktop


4

I ran into a similar (the same?) issue on two different installs: NVIM v0.2.0 NVIM v0.3.1 As quanta already mentions this change in behavior might be due to the changes introduced in NVIM v0.2.1. I have a shortcut for running things from within nvim, that splits the window, launches the terminal emulator in the new split view and executes there. After ...


3

This patch on fugitive fixes this issue (and here's the PR). It looks like I was running an old version of fugitive. Upgrading to the latest fugitive fixed this issue for me.


3

While I don't think it's possible out of the box, you can work your way around this: command! -nargs=1 GGrep Ggrep <q-args> -- './*' ':(exclude)*.map' Then use the GGrep command instead of Ggrep: :GGrep foobar See: :h command :h nargs :h <q-args>


3

On line 1019 of plugin/fugive.vim we can see how the :Gcommit command executes git: noautocmd silent execute '!'.command.' > '.outfile.' 2> '.errorfile With the variables replaced, the command looks like: !env GIT_EDITOR=false git --git-dir=/home/martin/git-test/.git commit > /tmp/vC4Lbak/1 2> /tmp/vC4Lbak/2 Notice the env GIT_EDITOR=false, ...


3

The highlight group is hi gitcommitOverflow. however it's part of vim's built-in syntax file gitcommit.vim, not in any way part of fugitive (besides having the same maintainer). Strangely, it looks like it was intended to be linked to Error by default but this was commented out. "hi def link gitcommitOverflow Error Putting this line in your custom ...


3

You can create a buffer like this with the 'buftype' option: :set buftype=nofile As :help 'buftype' explains: The value of this option specifies the type of a buffer: <empty> normal buffer nofile buffer which is not related to a file and will not be written See :help special-buffers for more background on this and ...


3

I don't believe it's possible to redefine :Glog without losing access to the script-local function. However, bearing in mind your muscle memory is for glog, not Glog, I propose another approach: cnoreabbrev <expr> glog (getcmdtype() == ':' && getcmdpos() == 5) ? 'Gitv' : 'glog' This abbreviation will convert your :glog commands into :Gitv ...


3

According to vim-fugitive sources, you can use Fugitive commands for any file that belongs to git index. E.g. cd ~ vim ~/home/foo/repo/README.md # works vim ~/home/bar/README.md # works too


3

I rarely ever run :Gpush on its own, so maybe try this: :Gstatus in the new split view, use - to toggle which changes you want to stage for the commit, then use cc to commit. After entering the commit message and save/quit, the split window shows unpushed commits; you can use - to push individual commits. The exact push line and parameters are shown in ...


3

You can use the <buffer> argument to restrict a map to a certain filetype, see :help :map-local for details. Fugitive's status filetype is fugitive, so you can try: augroup FugitiveMappings autocmd! autocmd FileType fugitive nmap <buffer> <Tab> = augroup You can also call the right function instead of mapping <Tab> to = (which ...


2

Thats because you should be on a fugitive-revision for that to work. (:h fugitive-revision).


2

The answer provided by @kubek2k is so phenomenal. That solution is better than I could have imagined and implemented in in less lines of code that I could have imaged. It opened the door to help me understand the powerful personalization use of 'fzf'. I have slightly modified it to additionally provide: Makes use of fugitive to get the refs instead of ...


2

Here is what I came up with to put in your ~/.vimrc: augroup vimrc_fugitive_status autocmd! autocmd BufEnter index if get(b:, 'fugitive_type') == 'index' | call <SID>fugitive_status_mappings() | endif augroup END function! s:fugitive_status_mappings() if get(b:, 'status_mappings', 0) == 0 call s:map_with_preview('dd', 'n') call s:...


Only top voted, non community-wiki answers of a minimum length are eligible