I'm trying to use vimdiff as a diff tool for Git but, for some reason, the files are always open in read-only mode. It makes sense for the original file but not for the ones that I have modified (since I haven't committed them yet).
This is my current .gitconfig:
[diff] tool = vimdiff [merge] tool = vimdiff [difftool] prompt = false
Any idea what could be causing this?
If you want to review and edit your currently pending changeset in GIT vimdiff can be very handy. The regular git diff will simply output differences in patch format. If you set up GIT to use vimdiff as diff tool you will be able to see the differences in VIM's split window view and be able to edit them too.
By default, git calls vimdiff with the -R option. You can override it with git config --global difftool.
The deafult command that git uses for vimdiff is: (found by inspecting process list)
vim -R -f -d -c "wincmd l" -c 'cd "$GIT_PREFIX"' "$LOCAL" "$REMOTE"
You can override this (to not use -R
, readonly mode) by setting the difftool.vimdiff.cmd
variable.
$ git config --global difftool.vimdiff.cmd 'vim -f -d -c "wincmd l" -c '\''cd "$GIT_PREFIX"'\'' "$LOCAL" "$REMOTE"'
The quoting is tricky. I would copy-paste it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With