Git (windows); P4merge as mergetool error - windows

I've tried setting up p4merge as my mergetool, but I can't seem to get it working. Here's my commands:
git config --global merge.tool p4merge
git config --global mergetool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"
git config --global mergetool.p4merge.cmd "p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\""
And here's the error I'm getting:
I've also tried installing a portable version of git and running the commands from a windows cmd prompt and I still get a similar error.
Any ideas here? I'm stumped.
Edit
Strangely enough, after I've set up p4merge via git bash and it failed, I tried merging in Visual Studio's Team Explorer and it launched p4merge (tableflip). I imagine the command that kicks off via VS is similar to git bash, but I'm not sure how to correlate the two.
Edit 2:
Here's my git status showing my merge conflict status:

First, try those same config command form a regular cmd session (as I mentioned in "escape double quotes in git config from cmd").
Just make sure you have unzipped the latest git-for-windows
(PortableGit-2.8.3-64-bit.7z.exe) in, for instance, C:\git, and added C:\git\bin to your %PATH%.
Second make sure you have files that need merging, ie. that have unresolved merge conflicts (with merge conflict markers in them), in order for git mergetool to work.

Related

Getting "command not found" error message when running "git log" on Windows

I have installed git and all the commands work properly except git log. When I type git log, this message appears:
command not found
what could be the possible reason for such a strange behaviour?
$ git --version
git version 2.16.1.windows.4
$ which git
/mingx64/bin/git
I just found the solution and wanted to share it with those who may come across the same error. It seems git log uses PAGER to show the messages and what I did was to use the git config --global core.pager '' command to stop git from using PAGER.
I've encountered this issue (or something similar to it).
Check inside your git config file, which you can find by running git config --list --show-origin
Check to see if you have any properties appended to that file that look incorrect.
For my issue, I had:
[core]
fsmonitor ==
Which was incorrectly setting a git property to an inappropriate value, causing the output to be: =: =: command not found

How to fix git commit on windows: "Waiting ... to close ... file: ... vim.exe: C:/Program: No such file or directory"

Does anyone know how to fix this error? Everything worked fine a few days ago in this same repository. Now that I'm trying to commit new changes, I get this error that I cannot fix. As far as I know, nothing has changed except for some Windows updates from patch Tuesday.
$ git commit
hint: Waiting for your editor to close the file... C:/Program Files/Git/usr/bin/vim.exe: C:/Program: No such file or directory
error: There was a problem with the editor 'C:/Program Files/Git/usr/bin/vim.exe'.
Please supply the message using either -m or -F option.
$ git config --global core.editor
C:/Program Files/Git/usr/bin/vim.exe
I've upgraded git for windows to the latest, but that didn't help. The error doesn't make any sense; vim runs fine. It says that git is waiting for vim to close "C:/Program", but that sounds like git passed vim a full path but forgot to escape the space. How could that happen?
You need to fix quotes in your .gitconfig:
git config --global core.editor "'C:/Program Files/Git/usr/bin/vim.exe'"

Changing Git core editor to Notepad++ causing issues

I use Windows 10 and a while back I changed the default Git editor to Notepad++
Now whenever I execute a command that brings up the editor I can't find any way of saving the message & continuing with the command - I end up having to cancel i.e. CTRL + C
I don't have to have Notepad++ as the editor but I do need to be able to use Git properly.
What I've tried
Restoring the original editor (I wasn't able to find out how)
Finding a similar problem on Stack Overflow
Restoring the original editor (I wasn't able to find out how)
You can try:
cd /path/to/your/repo
git config --unset-all core.editor
git config -l|grep core.editor
(grep is available if you add your <git>/usr/bin to the Windows %PATH%.
<git> is the path where you have installed git)
If that does not work, you might have to remove it for your local and global config:
cd /path/to/your/repo
git config --local --unset-all core.editor
git config --global --unset-all core.editor
git config -l|grep core.editor

Removing winmerge from git

I have a Windows 7 computer at work that someone else used before I joined the company. They have git setup with winmerge. While it may be a good idea, I want to remove it and return to a basic "default" git installation.
I tried uninstalling git and gitextensions (which I found on the computer) and after the restart I reinstalled git. I still see the same winmerge options when I do git config --list.
Here is a screenshot of what it is telling me. How would I restore this computer to a default install without winmerge? Thanks in advance!
Screenshot from git config --list
Or here is the code (not that "$REMOTE" is from the previous line)
core.editor="C:/Program Files (x86)/GitExtensions/GitExtensions.exe" fileeditor
merge.tool=DiffMerge
diff.guitool=winmerge
credential.helper=!\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\"
difftool.winmerge.path=C:/Program Files (x86)/WinMerge/winmergeu.exe
difftool.winmerge.cmd="C:/Program Files (x86)/WinMerge/winmergeu.exe" -e -u "$LOCAL" "$REMOTE"
mergetool.DiffMerge.path=C:/Program Files (x86)/WinMerge/winmergeu.exe`
Like #AndrewC said in the comments, you can delete the .gitconfig file found in your user profile (C:\Users\User\.gitconfig).
Alternatively, you can do git config --global --edit and manually delete the lines from the file opened.

Git mergetool with Perforce

I am using Perforce to resolve file conflicts in Git.
To set this up, I ran
git config --global mergetool.p4merge.cmd 'p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"'
git config --global merge.tool p4merge
p4merge is available in the path.
When I run git mergetool after conflicts have arisen, p4merge issues the following error message:
Errors: "./myfile.BASE.7132.example" is an invalid file
"./myfile.LOCAL.7132.example" is an invalid file
"./myfile.REMOTE.7132.example" is an invalid file
"myfile.example is an invalid file
It is not taking the complete path of the files like c:\users\abc\project\path\myfile.example but seems to think they are in the root directory.
I am working on Windows.
How can I make Perforce to take correct paths of the files?

Resources