Git mergetool with Perforce - windows

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?

Related

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'"

Unable to set Meld as a diff tool in Git Bash

Can someone help me to figure out how can I make Meld work on Git Bash for Windows 10? I have followed some instructions but neither worked for me.
After I typed these commands, nothing happened:
git config --global diff.tool meld
git config --global difftool.meld.path "/c/Program Files(x86)/Meld/Meld.exe"
git config --global difftool.prompt false
After using git difftool command, I get this weird error:
git config option diff.tool set to unknown tool: merge
Resetting to default...
This message is displayed because 'diff.tool' is not configured.
See 'git difftool --tool-help' or 'git help config' for more details.
'git difftool' will now attempt to use one of the following tools:
opendiff kdiff3 tkdiff xxdiff meld kompare gvimdiff diffuse diffmerge ecmerge p4merge araxis bc codecompare emerge vimdiff
2 files to edit.
I also tried;
/c/Progra~2/meld/bin/
"/c/Program files (x86)/Meld/"
"c:/Program files (x86)/Meld/"
My config file:
[user]
name = user
email = email#sample.com
[merge]
tool = meld
[mergetool "meld"]
cmd = meld --auto-merge \"$LOCAL\" \"$BASE\" \"$REMOTE\" --output \"$MERGED\" --label \"MERGE (REMOTE BASE MY)\"
trustExitCode = false
[mergetool]
prompt = false
keepBackup = false
[diff]
guitool = meld
tool = meld
[difftool "meld"]
cmd = meld \"$LOCAL\" \"$REMOTE\" --label \"DIFF (ORIGINAL MY)\"
path = C:/Program Files(x86)/Meld/Meld.exe
[difftool]
prompt = false
Your path is not well written, and there is a missing space character.
And you should define cmd instead of path.
Eventually, this should work for you:
git config --global diff.tool meld
git config --global difftool.meld.cmd "\"C:/Program Files (x86)/Meld/Meld.exe\" \"\$LOCAL\" \"\$REMOTE\""
git config --global difftool.prompt false
Edit:
If you want Git guidelines of valid tools, you can check it with:
git difftool --tool-help
Anyway, after our exchanges, you decided to use P4merge; This is a consequent update of my answer.
This is the way to setup it:
git config --global merge.tool p4merge
git config --global mergetool.p4merge.cmd "\"C:/Program Files (x86)/Perforce/p4merge.exe\" \"\$LOCAL\" \"\$REMOTE\""
git config --global diff.tool p4merge
git config --global difftool.p4merge.cmd "\"C:/Program Files (x86)/Perforce/p4merge.exe\" \"\$LOCAL\" \"\$REMOTE\""
I'm also with Git Bash on Windows 10 and this config works fine with Meld :
diff.guitool=meld
merge.tool=meld
difftool.meld.path=C:/Program Files (x86)/Meld/meld/meld.exe
mergetool.meld.path=C:/Program Files (x86)/Meld/meld/meld.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

Git (windows); P4merge as mergetool error

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.

System level git config in mac

I am able to see global and local config files at usual locations.
But if i type
git config --system --list
it gives me
fatal: unable to read config file '/Library/Developer/CommandLineTools/usr/etc/gitconfig': No such file or directory
Any idea why it is looking there?
And why it is not set? Where is
system git config location for Mac?
There is no file at /etc/gitconfig or $HOME/.config/git (prescribed location got *nix and osx respectively)
EDIT
doing
sudo git config --system --list
does not help
#Abhijit Mazumder:
I know this is an old question, but I had a similar issue when attempting to set a system level git config value on my mac and thought I would post my solution here in case it could help you.
NOTE: I strongly suspect that if you simply create the
'/Library/Developer/CommandLineTools/usr/etc/' directory and create a
file called gitconfig within that directory, then your attempts at
viewing or setting system level git config values will be successful.
My first attempt at setting a system level git config value on my mac was:
git config --system alias.cl clone
This resulted in an error:
error: could not lock config file /Applications/Xcode.app/Contents/Developer/usr/etc/gitconfig: No such file or directory
I thought perhaps I needed to add 'sudo' to the command:
sudo git config --system alias.cl clone
But running the command with 'sudo' gave me the same error:
error: could not lock config file /Applications/Xcode.app/Contents/Developer/usr/etc/gitconfig: No such file or directory
So, from the root directory on my mac, I switched into the 'usr' directory mentioned in the error, just to see what was in there:
cd Applications/Xcode.app/Contents/Developer/usr/
I was surprised to find that there was no 'etc' directory. The only directories I saw were 'bin', 'lib', 'libexec', and 'share'.
So I decided to create what was missing. I first created an 'etc' directory:
sudo mkdir etc
And then created a gitconfig file in the 'etc' directory:
sudo touch etc/gitconfig
I was then able to set a system level git config value with the following command:
sudo git config --system alias.cl clone
In order to confirm that the system level git config value had actually been set, I viewed the contents of the gitconfig file.
I first used the unix 'cat' command while inside my 'usr' directory:
cat etc/gitconfig
The output from the 'cat' command was:
[alias]
cl = clone
Then I used a git command (the same one you were trying to use in your question) to check that my system level git config value had been set:
git config --system --list
The output from this command was:
alias.cl=clone
The last thing I needed to do to ensure that I had placed my file in the proper location was try the alias I had created, so I tried running:
git cl
Running this command using the alias I created resulted in the following output, which confirmed for me that everything was working properly:
You must specify a repository to clone.
usage: git clone [<options>] [--] <repo> [<dir>]
-v, --verbose be more verbose
-q, --quiet be more quiet
--progress force progress reporting
-n, --no-checkout don't create a checkout
--bare create a bare repository
--mirror create a mirror repository (implies bare)
-l, --local to clone from a local repository
--no-hardlinks don't use local hardlinks, always copy
-s, --shared setup as shared repository
--recursive initialize submodules in the clone
--recurse-submodules initialize submodules in the clone
--template <template-directory>
directory from which templates will be used
--reference <repo> reference repository
--dissociate use --reference only while cloning
-o, --origin <name> use <name> instead of 'origin' to track upstream
-b, --branch <branch>
checkout <branch> instead of the remote's HEAD
-u, --upload-pack <path>
path to git-upload-pack on the remote
--depth <depth> create a shallow clone of that depth
--single-branch clone only one branch, HEAD or --branch
--separate-git-dir <gitdir>
separate git dir from working tree
-c, --config <key=value>
set config inside the new repository
I have not come across this error as my machines are only used by me so setting --global level is enough, however that location looks reasonable (I assume you are using the git supplied with the Xcode command line tools).
Using sudo to configure what you want should work:
$ sudo git config --system <name> <value>

Resources