Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent git vimdiff from opening files as read-only?

Tags:

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?

like image 476
laurent Avatar asked Aug 31 '13 03:08

laurent


People also ask

What is Vimdiff git?

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.

Which command configure the use of Vimdiff as the default diff tool in git?

By default, git calls vimdiff with the -R option. You can override it with git config --global difftool.


1 Answers

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.

like image 85
bukzor Avatar answered Sep 27 '22 19:09

bukzor