How to stage all modified and new files with vim-fugitive

2.8k views Asked by At

I know that you can use GWrite to stage current file. You can also use GStatus and - to stage the file you are selecting.

Is there a way to GWrite all the files or do git add . without using GStatus ?

4

There are 4 answers

0
leaf On BEST ANSWER

See :h :Git, which can

Run an arbitrary git command. Similar to :!git [args] but chdir to the repository tree first.

:Git add .
0
nemo On

I think you can just add a number before -. E.g. 5- to stage/unstage 5 of them.

0
dex On

Not the answer to your specific question but something I've learned from one of the screencasts specified in github/tpope/vim-fugitive/README.markdown is you can do a visual select all file lines, - to stage them all, then cc to commit, all from within the Gstatus screen.

0
Stanislav On

Now I have the following in my .vimrc:

augroup custom_fugitive_mappings
    " delete custom_fugitive_mappings to avoid double runs
    au!
    " map 'A' to stage all in git status window
    au User FugitiveIndex nnoremap <buffer> A :Git add .<cr>
augroup END