Questions tagged [git]

Questions about the integration of the Git revision control system in Vim or about the synchronisation of Vim files via Git repositories.

Filter by
Sorted by
Tagged with
44
votes
2answers
11k views

How do I open a file from another git branch?

I'd like to open a file from another branch in the current git repository. I have seen this SO question, but the suggestions for combining it with Vim are cumbersome (pipe to Vim, open stdin, set ...
23
votes
6answers
10k views

Easiest way to switch git branches

Right now I'm using fugitive to manage almost everything git related, but I can't find a good workflow to quickly visualize and switch between available branches. I can do :Git checkout <branch-...
19
votes
5answers
6k views

Git Fugitive how to git add a visually selected chunk of code

I would like to know if i could select some code in visual mode and git add it ? I checked with fugitive.vim but i didn't find how to do it. Is it possible ? Or is there any other plugin to do it ?
12
votes
2answers
2k views

How to detect whether swp files contain unsaved changes?

When editing source code using gvim (v.7.4.488), I want to commit some changes the vcs (I'm using git 2.1.4 from the command line in Ubuntu linux). git --status shows which files I changed. However,...
9
votes
6answers
1k views

How to load list of files in commit into quickfix

Using git how can I load the list of files in the current commit into Quickfix window? Code Review didn't pass and I want to just fix them one by one.
7
votes
2answers
2k views

Git mergetool vimdiff command

I'm attempting to get something setup that invokes the vimdiff git merge tool externally, but because of the way the setup works, I need to invoke vimdiff manually (without git mergetool). Does anyone ...
7
votes
1answer
273 views

Open git tracked files inside editor

I'm trying to make a Vim command which opens all modified files tracked by Git. The following command works if there is only one modified file (and fails if the current working directory is not a git ...
6
votes
1answer
223 views

Can I detect whether current vim instance is launched by git?

My .vimrc does a lot of extra things I don't want to do if it's launched by git(for example, during commit), since the purpose of that Vim instance is very specific so it makes no sense to launch many ...
6
votes
1answer
1k views

Warning when opening commit message with Neovim

I've been using Neovim for a few days with no problem, so I decided to switch my git config to use Neovim instead of vim. Here's what I put in my global .gitconfig: [core] editor = nvim And here'...
6
votes
1answer
1k views

How to manage fugitive commit with a git pre-commit hook?

When working on a git project in vim, I use the fugitive plugin. I like to open a :Gstatus split, press - to add file and then press C to commit my changes. I also have a git pre-commit hook, it runs ...
5
votes
3answers
904 views

Keeping personal vimrc and syntax files etc in source control?

I am trying to create a (git) repository for my vim files. Now, I am already struggling as to what directory I would store my files under. As far as I can see there is either %HOME% or %VIM%, right? ...
5
votes
1answer
294 views

IDE-like inline diff highlighting in Vim

I enjoy using Vim and like it better than IDEs on most points. One common IDE feature that I miss, though, is inline diff highlighting: In this example changed lines are highlighted in blue and ...
5
votes
2answers
250 views

Turn Vim's multiple undo history into git commits?

When refactoring I sometimes do too much at once—all little steps, but I forget to commit after each little change. Of course in many cases a commit after each change would be too much, but if each ...
5
votes
1answer
503 views

Vim Function to Send Highlighted Text to a Git Commit

Problem: Suppose I have the following text in my vim buffer: This is a commit msg. Suppose further I have a git repo located at ~/my_repo. Goal: Make a vim script so that I can highlight the text ...
5
votes
1answer
376 views

Make autoformating insert a line break instead of two spaces after full stop

I noticed that vi's auto format adds two spaces after a full stop. I wonder how this can be changed, i.e., insert just one space after a full stop, or even a line break. The application is in using a ...
4
votes
1answer
950 views

VimDiff incorrectly showing all lines as changed

I am using Vim with fugitive.vim plugin. Sometimes when diffing files versus their HEAD version from Fugitive's Gstatus window, Vim shows all lines in a file as changed, when in reality only one or ...
4
votes
1answer
3k views

Populate a git-commit-template with variables

I've followed this tutorial to set up a nice git-commit-template and use it with Vim. I would like to put this one step further and make possible to have in my template a preconfigured variable with ...
4
votes
1answer
4k views

Using vim diff to compare the working directory to the HEAD in git?

Is it possible to use vim diff to open and compare all the differences between HEAD and the files in the working directory?
4
votes
1answer
713 views

Can I show the git diff status on a per-line basis?

I'd like to be able to see which lines in my file have been edited relative to the current git head, is there any way I can do this? In particular, I'd like to be able to tell if a line was added or ...
4
votes
2answers
521 views

How to break-up gutter fights?

There a number of types of plugins use the Vim gutter to display Git status, syntax correctness, linting and code formatting. But how can conflicts be managed when multiple plugins want to update the ...
4
votes
1answer
130 views

Who manages the vim-scripts project on Github, and how is it used?

I'm referring to this. Are there package managers that pull scripts from it by name? I ask because I notice that the version of my plugin contained in it is extremely old, and I'm wondering whether I ...
4
votes
1answer
2k views

Vim black text on black background in command line in Windows 10 while editing git commit message

I am using git 2.7.0.windows.1 in Windows 10, with core.editor set to vim. Vim was downloaded from vim.org latest version binary: VIM - Vi IMproved 7.4.1023 (2013 Aug 10, compiled Jan 2 2016 14:24:...
3
votes
1answer
447 views

Is there a way to hook ctag changes to git branch checkouts and pulls?

When I checkout different branches, I sometimes notice that files in the repo are not available to Vim plugins that search based on the ctags index. I don't have a definitive test that's shown the ...
3
votes
1answer
141 views

shared vimrc on two machines; only run command for one of them

I use git to share my vimrc across multiple machines. But now I have some commands which I only want on one machine. Namely, this line: au! redhat BufReadPost (derived from this very helpful answer! ...
3
votes
1answer
148 views

How do I get back to the current working copy while viewing git revisions?

When using :Glog or other git plugins like :GV (gitv?) and checking revisions or commit you end up in Read-Only mode viewing something like fugitive:///.git//300ed70aa473b7e8f983a2590c2af908cd0a0621/...
3
votes
1answer
103 views

How to display the counts of lines in a git patch / hunk?

In git when patching you have to count: The "leave alone" lines The "remove" lines The "add" lines The "leave alone" + "add" lines I've found ways to count all of these... %s/^ / /n "leave alone" %...
3
votes
1answer
2k views

Undo diffget in vimdiff

Say I have a merge conflict in Git, and try to resolve it with vimdiff using diff3 view. Here is a screenshot: Now while resolving, I want to diffget once from LO see how it looks like, undo, and ...
2
votes
2answers
980 views

Review: git branch in statusline

Note: this is an educational exercise. For those wanting a ready-made solution, use vim-gitbranch. I am learning vimscript, and the code below is part of my .vimrc used to display the current git ...
2
votes
1answer
83 views

file name completion in .gitignore

I often "unignore" files in .gitignore, like this: * !.gitignore !file.txt !dir !dir/* Can I modify the pattern for which insert mode file name completion would work? In this case, instead of ./ I'd ...
2
votes
1answer
567 views

How to get Vim to show git status in the statusline?

I want to show the git status in the vim statusline, but I can't find any advice on how to do that. The output of git status -s would be fine, or alternatively a single field readout indicating ...
2
votes
1answer
118 views

How to load commits in a certain date range with fugitive?

I am able to do git log --pretty=format:"%h" --after="2018-06-7" --until="2018-06-10", in the shell, but if I try to do it in vim with fugitive like this: :Glog --after="2018-6-7" --until="2018-06-10"...
2
votes
1answer
643 views

Why “there was a problem with vi” when saving a git commit message with :wq after accidental :Wq?

When I have typed a commit message with vim and, in haste, typed :Wq instead of :wq I get an error: E492: Not an editor command: Wq from which I can (falsly?) recover, meaning the editor seems to ...
2
votes
1answer
613 views

How to use ~/.vimrc for vimdiff

How can I get git's difftool, when using vimdiff, to use my ~/.vimrc file?
2
votes
0answers
401 views

Why does Git think Vi quit in error?

Is there anything wrong with opening up a new vim tab (for scratch work) while authoring a git commit? Update: This Seems to Be a Quirk With Vi vs. Vim On further inspection prompted by @muru's ...
2
votes
0answers
86 views

Mvimdiff launches with vertical split on far right

I'm trying to integrate mvimdiff into my workflow - but when I launch it via: git difftool <filename> I'm getting a wonky layout like this: _________________________ | | |...
1
vote
2answers
130 views

Commiting pathogen bundles?

Right now I am using Pathogen to manage bundles in my ~/.vim folder. I also have my public dotfiles repo which has all my configs, including my entire .vim folder. I don't use symlinks to do this, ...
1
vote
1answer
929 views

`vimdiff` nor `nvim -d` are working as an external diff tool for git

First line says output is not a terminal. The rest of the output looks like term codes aren't being processed. I use st, with $TERM = st-256color. I just tried it on termite ($TERM = xterm-termite) ...
1
vote
1answer
1k views

Visualize git commit diff similarly to mergetool

I've been thinking of ways to visualize git commits with vim. I would like to be able to: run a command from the terminal such as: vimdiff -c <commit id>. vim opens with two windows on a ...
1
vote
1answer
60 views

Why is the commit message inside parentheses wrapped so strangely?

I sometimes need to do some remarks in parentheses in my commit message's detailed part. But when the parenthesized text comes to the rightmost column and is line-broken, the next line for some reason ...
1
vote
1answer
437 views

diffpatch using the output of git diff directly

I guess many of you are like me, and even if they have been using ViM for years, still learn new features regularly. The last that I learned was :diffp[atch] patch/name Now, I want to combine it ...
1
vote
1answer
739 views

How to use pure Vim as git mergetool?

Whenever there are some git merge conflicts we would type git mergetool and git would automatically launch a merge tool for us to merge the conflicts. I have been using vimdiff for a long time as my ...
1
vote
1answer
94 views

Git submodules for syntax files

I keep my VIM folder under git version control. I use git submodules and Pathogen to keep my VIM plugins updated. The folder structure is .vim/bundle/$PLUGIN Is it possible to use git submodules for ...
1
vote
1answer
47 views

Is there a Vim plugin similar to Git History Diff?

I like the extension Git History Diff in Visual Studio Code, looks something like this: I am looking for something similar for Vim. I've looked at Fugitive and other Vim plugins, but they are awkward ...
1
vote
1answer
85 views

Edit in .vimrc but it's not updated in .git

So I was editing my ~/.vimrc file from the home directory and saved it, but when I went to check whether it had been updated in the vimrc file (for git) which is located at /.vim/vimrc, it did not ...
1
vote
1answer
113 views

Retrieving failed fugitive commit message

I PGP sign my commit messages, and every once in a while GPG will fail for whatever reason (invalid cache, incorrect pin, etc), and my fugitive buffer will close, loosing all my changes. It doesn't ...
1
vote
1answer
135 views

Vim (Spacevim); :!git push == permission denied (publickey)

I have operating system: Windows 7. Git bash works fine for me, and it uses the public key id_rsa.pub. I can run git commands fine through window's command prompt as well - and it too uses the public ...
1
vote
1answer
401 views

How to customize the color of an HTML output file generated from Git Bash?

I have used the following command in Git Bash to perform a 'vimdiff' for 2 XML files. vimdiff xml1.xml xml2.xml -c TOhtml -c 'w! result.html' -c 'qa!' The HTML file which is getting generated is ...
1
vote
0answers
39 views

GitGutter sign not working

I have airblade/vim-gitgutter installed via Vundle. Somehow even with minimal .vimrc vim-gitgutter signs aren't working. My minimal .vimrc is given below, is there any problem there? Any help will be ...
1
vote
0answers
51 views

Folding for git merge candidates is (at least to me) backwards

When viewing a merge candidate created by git you will have something like . . . Some stuff not in conflict <<<<<< HEAD Some stuff ====== Something different >>>>>...
1
vote
1answer
187 views

Saving .swp/.un~ files to subdirectories

Is there any way to save these files to automatically created subdirs? Google gave me no answers. The reason is simple- I work on several computers which I keep synced via git, so having these files ...