How to install patchutils on Windows 10 - windows

I already have Git and Git Bash installed. I find it inconvenient to create an "interdiff" between two patch files in Git Bash using only git commands. I would like to install patchutils, so that I can use the interdiff command -- and thus create interdiffs using the patch files directly, without committing code first.
How do I install patchutils such that I can use it from Git Bash? I tried npm install patchutils, but no success.

Another approach to this issue would be to use MSYS2 instead of "Git Bash".
MSYS2 has its own Git package, and it has a PatchUtils package:
https://packages.msys2.org/base/patchutils

Related

Package management in Git for Windows (Git Bash)?

I'm reading the github wiki for git-for-windows and it says that msys2 bundles pacman: https://github.com/git-for-windows/git/wiki/Package-management
But when I invoke it I get:
$ pacman
bash: pacman: command not found
Does anyone have an idea what is going on?
Which git version does this wiki refer to?
Is there a way to install additional packages to msys2 inside Git for windows?
As mentioned in issue 397:
This is intended. We do not ship pacman with Git for Windows.
If you are interested in a fully fledged package manager maintained environment you have to give the Git for Windows SDK a try.
The bash that you see in the latest git for Windows (2.5.3), which is a more recent bash than the old msysgit one, is only there to execute git commands.
It is not a full-fledged linux environment to install any third-party package.
Warning: dhj reports in the comments
Do not link your existing git for windows with the msys2 main system by using a directory junction.
If you uninstall it will decide that linked directory belongs to it and DELETE YOUR ENTIRE HOME DIRECTORY including sub-directories like "Downloads".
Beware dealing with msys2.
I don't know if the same is true for the git for windows SDK, but BE CAREFUL trying to get pacman from other systems integrated with git for windows.
Git for Windows (https://gitforwindows.org/ or https://git-scm.com/downloads) has Git Bash but it does not include tree.
tree is available via pacman (Package Manager), but that is only available if you install "Git for Windows SDK" (scroll to the bottom of https://gitforwindows.org/ which provides a link to download installer for it from https://github.com/git-for-windows/build-extra/releases/latest)
The accepted answer was very helpful. They mention that git-for-windows was not meant to include pacman in the default install.
So I installed "Git for Windows SDK", then in its bash prompt (SDK-64) I ran the
following to install current tree v1.7.0-1 (as of this posting Aug 30, 2018):
[SDK-64: Bash Terminal for Git for Windows SDK]
pacman -S tree
...
Proceed with installation? [Y/n] Y
On my system, Git for Windows SDK is installed under: C:\git-sdk-64, so from my Git for Windows Bash shell (which did not have tree installed), I copied it over tree.exe to its /usr/bin directory, e.g.
[MINGW64: Bash Terminal for Git for Windows]
cd /usr/bin
cp /c/git-sdk-64/usr/bin/tree.exe .
Now I can run tree v1.7.0 from both Git Bash shells.
To make it even easier for others and maybe myself on a future machine, I looked at where pacman was getting the tree package from by running the following in my Git for Windows SDK Bash terminal:
$ pacman -S --info tree
Repository : msys
Name : tree
Version : 1.7.0-1
Description : A directory listing program displaying a depth indented list of files
Architecture : x86_64
...
The key thing here is that pacman is getting tree from the "msys" repository (FYI: even though it says msys, it really is using msys2), so I looked at /etc/pacman.d/mirrorlist.msys and the first mirror points to http://repo.msys2.org/msys/$arch/
So next time you want a package that is NOT in Git for Windows, you can download them from: http://repo.msys2.org/msys/x86_64/ (for 64-bit) or from http://repo.msys2.org/msys/i686/ (32-bit)
e.g. direct download link for tree v1.7.0-1
64-bit: http://repo.msys2.org/msys/x86_64/tree-1.7.0-1-x86_64.pkg.tar.xz
or https://sourceforge.net/projects/msys2/files/REPOS/MSYS2/x86_64/tree-1.7.0-1-x86_64.pkg.tar.xz
32-bit: http://repo.msys2.org/msys/i686/tree-1.7.0-1-i686.pkg.tar.xz
or https://sourceforge.net/projects/msys2/files/REPOS/MSYS2/i686/tree-1.7.0-1-i686.pkg.tar.xz
FYI: Git SCM's Window's download at https://git-scm.com/download/ pulls the latest from Git for Windows GitHub (https://github.com/git-for-windows/git from the https://github.com/git-for-windows/git/releases/ link)
I did not want to move from my already working Git for Windows installation so I improvised a bit:
Install Git for Windows SDK somewhere else. You'll need more than 3 GB of free space for that.
Copy ${git-sdk}/usr/bin/pacman.exe to ${git}/usr/bin
Copy ${git-sdk}/etc/pacman.conf and ${git-sdk}/etc/pacman.d to ${git}/etc
Copy ${git-sdk}/var to ${git}/
That's all. You can now open your Git Bash and run pacman -S python to install packages on your existing Git for Windows setup.
You will need write access to Git for Windows directory. Also, your pacman now thinks it has a lot of packages installed (from SDK) but it did not stop me from using it.
"Git for Windows SDK" is 5.33GB compared to "Git for Windows" 691MB compared to "Portable Git" 275MB. I use the lean and mean Portable Git. At first, it seems hopeless trying to restore and use pacman in the latter two flavors of Git (msys2), because Google excluded ALL metadata files in /var/lib/pacman/local. Please read this official explanation:
https://wiki.archlinux.org/index.php/Pacman#.22Failed_to_commit_transaction_.28conflicting_files.29.22_error
Without those metadata files, you don't know the exact collection and version of the msys2 packages Google selected to build a release of those 2 flavors of Git. If you force to install or copy the current version of msys2 packages, you run the risk of version mismatch with git binaries Google built and tested.
Well, that's until I discover this file: /etc/package-versions.txt, the laundry list of matching msys2 packages and versions. Now there is a definitive source in github. Here is how I restore pacman in Portable Git (commands can be copy & paste into git-bash shell all at once):
Step 1: Run these commands to download /etc/pacman.conf and 3 packages: pacman, pacman-mirrors and msys2-keyring. See my Dec 9, 2022 comment below on why you need zstd in .xz format. These packages/versions were tested on both 32 and 64-bit Portable Git 2.38.1:
if [[ "$HOSTTYPE" == "i686" ]]; then
pacman="
pacman-6.0.0-4-i686.pkg.tar.zst
pacman-mirrors-20210703-1-any.pkg.tar.zst
msys2-keyring-1~20210213-2-any.pkg.tar.zst
"
zstd=zstd-1.5.0-1-i686.pkg.tar.xz
else
pacman="
pacman-6.0.1-18-x86_64.pkg.tar.zst
pacman-mirrors-20220205-1-any.pkg.tar.zst
msys2-keyring-1~20220623-1-any.pkg.tar.zst
"
zstd=zstd-1.5.2-1-x86_64.pkg.tar.xz
fi
for f in $pacman; do curl https://repo.msys2.org/msys/$HOSTTYPE/$f -fo ~/Downloads/$f; done
curl -L https://github.com/mcgitty/pacman-for-git/raw/main/$zstd -o ~/Downloads/$zstd
curl https://raw.githubusercontent.com/msys2/MSYS2-packages/7858ee9c236402adf569ac7cff6beb1f883ab67c/pacman/pacman.conf -o /etc/pacman.conf
Step 2: Unpack them at the root then restore pacman with these commands:
cd /
tar x --xz -vf ~/Downloads/$zstd usr
for f in $pacman; do tar x --zstd -vf ~/Downloads/$f usr etc 2>/dev/nul; done
mkdir -p /var/lib/pacman
pacman-key --init
pacman-key --populate msys2
pacman -Syu
Step 3: The next set of commands restore all matching metadata (be patient). Like the zstd packages in Step 1, this relies on my public github repo pacman-for-git to provide the git-sdk commit ID of each Portable Git release, which I'll do my best to update:
t=`grep -E 'mingw-w64-[ix_0-9]+-git ' /etc/package-versions.txt`
t=`curl -sL https://github.com/mcgitty/pacman-for-git/raw/main/version-tags.txt|grep "$t"`
[[ "$t" == "" ]] && echo "ERROR: Commit ID not logged in github pacman-for-git." && read
b=64 && [[ "$t" == *-i686-* ]] && b=32
URL=https://github.com/git-for-windows/git-sdk-$b/raw/${t##* }
cat /etc/package-versions.txt | while read p v; do d=/var/lib/pacman/local/$p-$v;
mkdir -p $d; echo $d; for f in desc files mtree; do curl -fsSL "$URL$d/$f" -o $d/$f;
done; [[ ! -f $d/desc ]] && rmdir $d; done
Step 4: Now, is it too much to ask for 'make' and 'zip'?
pacman -S make zip
Voilà, still just a 337MB mean little environment that can expand and upgrade!
There seems to be a documented way to do this without having to install the Git for Windows SDK (which is very large). I was given the link to this info by PhilipOakley when I asked about all this on GitHub issue #1912.
Here's the current text of the Git for Windows GitHub wiki page about it:
##Install inside MSYS2 proper
###Please note that this scenario is not officially supported by Git for Windows
(The reason this is unsupported is that there are no volunteers to support that scenario.)
This guide assumes that you want the 64-bit version of Git for Windows.
Git for Windows being based on MSYS2, it's possible to install the git package into an existing MSYS2 installation. That means that if you are already using MSYS2 on your computer, you can use Git for Windows without running the full installer or using the portable version.
Note however that there are some caveats for going this way. Git for Windows created some patches for msys2-runtime that have not been sent upstream. (This had been planned, but it was determined in issue #284 that it would probably not be happening.) This means that you have to install Git for Windows customized msys2-runtime to have a fully working git inside MSYS2.
Here the steps to take:
Open an MSYS2 terminal.
Edit /etc/pacman.conf and just before [mingw32] (line #71 on my machine), add the git-for-windows packages repository:
[git-for-windows] Server = https://wingit.blob.core.windows.net/x86-64
and optionally also the MINGW-only repository for the opposite architecture (i.e. MINGW32 for 64-bit SDK):
[git-for-windows-mingw32] Server = https://wingit.blob.core.windows.net/i686
Authorize signing key (this step may have to be repeated occasionally until https://github.com/msys2/msys2/issues/62 is fixed)
curl -L https://raw.githubusercontent.com/git-for-windows/build-extra/master/git-for-windows-keyring/git-for-windows.gpg | pacman-key --add - && pacman-key --lsign-key 1A9F3986
Then synchronize new repository
pacboy update
This updates msys2-runtime and therefore will ask you to close the window (not just exit the pacman process). Don't panic, simply close all currently open MSYS2 shells and MSYS2 programs. Double-check Task Manager and kill pacman.exe it's still running after the window is closed, because it can linger. Once all are closed, start a new terminal again.
Then synchronize again (updating the non-core part of the packages):
pacboy update
And finally install the Git/cURL packages:
pacboy sync git:x git-doc-html:x git-doc-man:x git-extra: curl:x
Finally, check that everything went well by doing git --version in a MINGW64 shell and it should output something like git version 2.14.1.windows.1 (or newer).
#VonC pointed out in the comments that there is discussion about possible additional steps needed in this approach, around half-way down the discussion at https://github.com/git-for-windows/git/issues/2688.
And now, potentially a new way to achieve the required result too:
https://github.com/git-for-windows/git/issues/2688#issuecomment-772311418
Tested on msys2 20190524 on Windows 10 x86_64 1909 10.0.18363.752 and msys2 20220128 on Windows 11 x86_64 21H2 10.0.22000.434
Using regular Git for Windows.
Install msys2 (Version 20190524 is tested.) or Git for Windows SDK. (Not fully tested, but it should work.) Both include PacMan and Git.
Using VFS for Git for Windows or Scalar for Git for Windows (Aka Microsoft git). Method #1 (with some limitations)
Install VFSForGit ( https://github.com/microsoft/VFSForGit ).
Install Microsoft git ( https://github.com/microsoft/git ) with this option "Git from the command line and also from 3rd-party software" enabled.
Create a symbolic link named "git" in msys64\usr\bin\ pointing to C:\Program Files\Git\bin\git.exe . Execute the following command in cmd.exe, not in bash. mklink git "C:\Program Files\Git\bin\git.exe"
Clone a new gvfs repo. gvfs clone https://dev.azure.com/somebody/_git/somerepo. Only the gvfs command can not be executed on msys2.
Use the git command as you are on msys2 normally.
Using VFS for Git for Windows or Scalar for Git for Windows. Method #2
Virtual Filesystem for Git (formerly was GVFS. Official website https://vfsforgit.org/ ) is recommended. Version 2.22 & 2.26 are tested. Scalar (Official website https://github.com/microsoft/scalar ) is NOT recommended, nor completely tested.
Install GVFS and Git for Windows with GVFS patch. Or install Scalar for Git and Git for Windows with Scalar patch. NOT BOTH on the same machine. The default installation destination is C:\Program Files\Git.
Install msys2 x64 somewhere other than C:\Program Files\Git. By default, it is in C:\msys64.
Copy files and subfolders of msys2 (except /etc and git binaries. The msys2 comes without git from factory.) to Git for Windows VFS edition, and copy /etc/pacman.d and /etc/pacman.conf in msys64 folder to Git installation folder, overwrite existing files. It will update msys2 and MinGW runtime to the latest version. For PacMan, the necessary files are /usr/bin/pac* ; /etc/pacman.conf ; /etc/pacman.d/ ; /var ; /usr/bin/msys* ; .(Not fully tested.)
Setup terminal applications. Run C:\Program Files\Git\bin\bash.exe will launch the bash of Git for Windows. Run C:\Program Files\Git\usr\bin\bash.exe will launch bash of msys2. Configure the path of bash for terminal programs, such as Hyper Terminal. Since Git is in the system folder, terminal programs should be Run as administrator.
Config $PATH the environmental variable for GVFS. Run this command in Git Bash. export PATH=$PATH:/C/Program\ Files/GVFS or export PATH=$PATH:"/C/Program Files/GVFS". Or set environmental variables for GVFS in the system property of the control panel. Relogin to take effect. Sometimes this configuration does not work, but PacMan can still run.
Fix PacMan. Set executable permission for binaries. Fox example. chmod +x /usr/bin/pacman ; pacman-key --init ; pacman-key --populate msys2 ; pacman-key --refresh-keys ; pacman --sync pacman --refresh --sysupgrade --sysupgrade --overwrite "*" . Use the option --overwrite \* because some packages were installed by Git for Windows instead of PacMan.
pacman is compressed using zstd now.
So updated #michael-chen 's scenario (i use wsl's unzstd):
for f in pacman-6.0.1-25-x86_64.pkg.tar.zst pacman-mirrors-20221016-1-any.pkg.tar.zst msys2-keyring-1~20221024-1-any.pkg.tar.zst; do curl https://repo.msys2.org/msys/x86_64/$f -o ~/Downloads/$f; done
cd /
tar --use-compress-program=unzstd -xvf ~/Downloads/msys2-keyring-1~20221024-1-any.pkg.tar.zst usr
tar --use-compress-program=unzstd -xvf ~/Downloads/pacman-mirrors-20221016-1-any.pkg.tar.zst etc
tar --use-compress-program=unzstd -xvf ~/Downloads/pacman-6.0.1-25-x86_64.pkg.tar.zst usr
mkdir -p /var/lib/pacman
pacman-key --init
pacman-key --populate msys2
pacman -Sy
export URL=https://github.com/git-for-windows/git-sdk-64/raw/main
cat /etc/package-versions.txt | while read p v; do d=/var/lib/pacman/local/$p-$v; mkdir -p $d; echo $d; for f in desc files install mtree; do curl -sSL "$URL$d/$f" -o $d/$f; done; done
Copying pacman from msys2 works for me, at the end most people forget that you can use pacman for self update as pacman -Syy msys/pacman
Run in msys pacman -Ql pacman
Copy files listed that match
/etc/*.conf
/usr/bin
/usr/include
/usr/lib
/var/lib
And copy databases as well
/etc/pacman
At this point I already have a working pacman,I check it with pacman -Ss pacman but there are missing files so I run self refresh
pacman -Syy msys/pacman

Git instaweb on windows? got a error

Is it possible to use instaweb on windows?
I have a bare repository at D:/myrepo and I want to use instaweb to see it like
this
I have tried this command
git instaweb --httpd=webrick
But I got this error
git: 'instaweb' is not a git command. See 'git --help'.
Thanks in advance.
The instaweb command is not yet supported for Windows as of version 1.9.0. It's listed under 'Known issues' in the Windows release notes:
Known issues
• Some commands are not yet supported on Windows and excluded from the
installation; namely: git archimport, git cvsexportcommit, git
cvsimport, git cvsserver, git instaweb, git shell.
I got it working using git in MSYS2:
Install MSYS2
Install git:
pacman -S git
Install ruby (webrick is part of Ruby standard library):
pacman -S ruby
You may need to install the CGI.pm perl module using CPAN
And go:
git instaweb -d webrick

How to install go-sql-driver on Windows

I am trying to install go-sql-driver on Windows Vista but I am having problems with GOPATH.
I installed git as suggested and added GOPATH as a new user environment in Windows with path C:/users/A/desktop/go.
I ran go get github.com/go-sql-driver/mysql in the command line but it gives me this error:
C:\>go get github.com/go-sql-driver/mysql
go: missing Git command. See http://golang.org/s/gogetcmd
package github.com/go-sql-driver/mysql: exec: "git": executable file not found in %PATH%
When I go look at http://golang.org/s/gogetcmd it merely says download git. But it is already downloaded in my machine.
I also went ahead and created a new environement variable for PATH and set its path to the directory where git was installed but that did not help either.
What am I doing wrong?
Download the Windows version of Git from http://git-scm.com/downloads.
Run the downloaded executable file, currently Git-1.8.3-preview20130601.exe, which will start a Git Setup wizard to install Git.
Check Git Setup Options
Run Git from the Windows Command Prompt
Checkout as-is, commit Unix-style line endings
Check the installation by running:
C:\>git --version
git version 1.8.3.msysgit.0
Make sure Git is in the %PATH% environment variable and ensure Git is installed. If you cannot run git --version in the command prompt, then the Git binary directory isn't listed in your %PATH%. Fix this by adding Git to the path, close the command prompt, and run git --version in a new command prompt. If you're still having issues, then you might be having other problems.
Install the GIT BASH desktop app in your Windows PC. The download link is here. Once installed, open the shell and type:
go get -u github.com/go-sql-driver/mysql
This will install driver for Golang's MySQL database package

How to upgrade Git on Windows to the latest version

I just upgraded to Git 1.8.0.1 for Windows, from my previous version 1.7.9.mysysgit.0. I downloaded the new version from the Git site and installed through the normal Git installer EXE.
That said, when I fire up my terminal window, it still is showing that I am running Git version 1.7.9.mysysgit.0. When I type git --version from my prompt, the same thing.
I found this article on a similar issue with Git on Mac OS X, which leads me to believe that it has something to do with a faulty PATH, but I'm still pretty new at all this (five months self-taught), so I'm at a loss in how to translate this to Windows.
This problem arose when I began a new Ruby on Rails project and tried to push it up to Git. I added the remote:
git remote add origin git#github.com:brianscottk/blog.git
then:
git push -u origin master
I received the following error message:
fatal: https://github.com refs not found: did you run git update-server-info on the server?
Googling that error led me to this article, which prompted me to upgrade, and here I am.
Since Git 2.16.1(2) you can use
C:\> git update-git-for-windows
In version between 2.14.2 and 2.16.1, the command was
C:\> git update
(It was later renamed to avoid confusion with updating the local repository, e.g. like svn update does it.)
That command does not exist in Git 2.13 and before.
If this errors with "is not a git command" then either you don't actually have Git for Windows, or your version is very old.
In which case, simply get the latest installer from https://git-scm.com/download (check whether you want 32- or 64-bit) and run it to upgrade.
If you already have the latest version it does nothing, in which case you can manually run the installer to reinstall.
C:\> git update-git-for-windows
Git for Windows 2.17.0.windows.1 (64bit)
Up to date
First, check your Git version by using this command
git version
Then follow the case according to your Git version
Three cases:
If your Git version is 2.14.1 or earlier:
Uninstall Git, download the latest Git, and install it again.
And versions between 2.14.2 and 2.16.1:
Use command git update
If the version is equal to or greater than Git 2.16.1(2):
Use command git update-git-for-windows
Git Bash
Note, if you are instead looking to find out what version of Git Bash you are running, or want to see if you need to update Git Bash, it is part of Git for Windows.
So your Git Bash version is:
git --version
git version 2.23.0.windows.1
Note that it is technically different from Bash. On my same machine when I run:
echo $BASH_VERSION
4.4.23(1)-release
Git for Windows installer
To update to the latest version of Git and Git Bash, you can download and install the latest version of Git for Windows. As per this FAQ, settings/customizations should be preserved if they were installed in the appropriate configuration folders.
Note: Their installer is actually intelligently designed to do the right thing (though it doesn't tell you upfront that it defaults to your prior settings automatically!).
If you are doing an update, then every screen on the installer is pre-marked with the settings from your current (soon to be previous) install.
It is not showing you generic default settings. You do not need to look any of them up, or fear for breaking your carefully honed setup. Just leave everything as is, to retain your previous choices.
In fact, they made it even easier (if only it was clear that they did so).
There is a checkbox at the bottom [] Show only new settings (I don't remember the exact wording). Since nothing on the first screen changes when you mark the box, it is not exactly obvious what it is for. If you mark the box, then all of your current settings will be retained, and it will skip showing those (subsequent) settings screens to you. Only screens with newly introduced settings will be shown.
git update-git-for-windows
Alternatively, as others have noted, you can also update Git Bash and Git (by definition, both are always updated at the same time) from the Git Bash command line, via:
git update-git-for-windows
If you type git update, Git kindly reminds you that the command has been updated to git update-git-for-windows:
Warning! git update has been deprecated;
Please use git update-git-for-windows instead.
Git for Windows 2.26.0.windows.1 (64bit)
Up to date
Just give the following command with your command prompt.
git update-git-for-windows
This will ask you a confirmation as follows. Press Y to proceed.
Once the files are downloaded, continue with the normal installation procedures. You can check the Git version after finishing installation with the following command:
git version
For me, the result was as follows.
Update (26 September 2016): It is no longer needed to uninstall your previous version of Git to upgraded it to the latest; the installer package found at Git Windows download site takes care of all. Just follow the prompts.
For additional information, follow instructions at installing and upgrading Git.
If you just type
git update-git-for-windows
If you are having issues with it, run Bash as administrator or add the 'git.exe' path to the "allowed apps through controlled folder access".
If you have already installed Git, you can update Git with the command
git update-git-for-windows
to know the current version, use:
git --version
You can run these commands in the cmd prompt.
Check version: git --version
If your Git version is 2.27.0.windows.1 or earlier
If the version is equal to or greater than Git 2.27.0.windows.1
Use command git update-git-for-windows
If you want to see a video tutorial click here.
Just run:
git update-git-for-windows
Use git update-git-for-windows as in this session:
PS Z:\MERN-STACK-ECOMMERCE-PROJECT> git --version
git version 2.31.0.windows.1
PS Z:\MERN-STACK-ECOMMERCE-PROJECT> git update-git-for-windows
Git for Windows 2.31.0.windows.1 (64bit)
Update 2.33.1.windows.1 is available
Download and install Git for Windows 2.33.1 [N/y]? y
############################################################################################################ 100.0%-
############################################################################################################ 100.0%
PS Z:\MERN-STACK-ECOMMERCE-PROJECT> git --version
git version 2.33.1.windows.1
PS Z:\MERN-STACK-ECOMMERCE-PROJECT>
Using the command "where git" find out how command prompt picks up the version. Once you have the path, you can go ahead and uninstall / delete previous version completely. Then if you install and make sure the new installed location is in the path, it should just work fine.
Using git-friendly tools like cmder will make your life much easier. You don't really have to use dual boot or cygwin anymore since the support for git in windows is already top-notch now. (Git for windows installs msysgit which includes all necessary unix tools from MinGW. MinGW has been there for a while and is pretty stable. If you want you can install the full version of msysgit rather than Git for Windows. msysgit is available on Git for windows page at the bottom.)
You can use,
git update
Or if you are on a Windows machine, you can run the command below,
git update-git-for-windows
Based on Simon's answer, I first uninstalled the new version of Git. I then re-installed the new version of Git into the same directory as the old version, C:/RailsInstaller/Git, instead of the default directory C:/Git.
Now my Ruby on Rails terminal window shows that I am running the new Git version 1.8.0.
If you look at the most recent update on Git's website in the "git via git" section you will see an option to update your older version.
Here is the command that git has on their site:
git clone https://github.com/git/git
It worked for my version of git which was a 2.13.0.windows.1.
To check out your PATH variable, act as follows:
From the Desktop, right-click My Computer and click Properties.
Click the Advanced System Settings link in the left column.
In the System Properties window click the Environment Variables button.
Once there, scroll to get the Path row. You'll get a long string of paths (e.g., C:\windows\bin;C:\program files\git, etc.).
Find the line or lines where git is referenced. Then, make sure this path point to your Git 1.8.x installation. If not, delete it and add the real path to the newest Git version. At the end, you should only have one path in the string linking to Git.
I don't think your problem is related to Windows' global PATH environment variable, as remote is specific to repositories.
I recommend you to use Git under Cygwin. Git could work under Windows command line, but there may be some weird problems hard to figure out. Under Cygwin it's more nature and has fewer errors.
All you need is to type bash in Window CMD, and then start to use the Unix tools and commands. You can use a shortcut to load bash; it's as easy as use normal Windows CMD.
The same is true for Ruby on Rails and Ruby. I used RailsInstaller before, but I found using Cygwin to install Rails is more stable.
Finally, I'll suggest to install Ubuntu dual boot if you have time (about a month to get familiar with it). Windows is not very friendly to every Unix tools ultimately. You'll find all pain stopped.
On my Windows 10, > git update-git-for-windows refused to work with curl issues. Only the below command worked.
winget install --id Git.Git -e --source winget

override git from Xcode with homebrew version

I've installed XCode and therefore git is there as well. Since i want to have a newer version of git I installed using homebrew.
But the homebrew version of git is never called since my PATH looks like this
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
which means the /usr/bin/git is allways called before /usr/local/bin/git.
Is there a way to change that without changing the PATH?
Xcode is actually using the GIT that is stored in /Applications/Xcode.app/Contents/Developer/usr/bin. The same version of GIT gets installed in /usr/bin when you installed the command line tools as part of Xcode installation. So, you won't be able to change what Xcode is using (unless you are willing to muck with the contents of the Xcode package). If, from a terminal application, you want to use the homebrew-installed GIT then you have two options:
Reference GIT with the full path as /usr/local/bin/git ... For this case you can create an alias like alias mgit=/usr/local/bin/git and then use mgit ... from the terminal
Change the path as PATH=/usr/local/bin:$PATH either in your .bashrc or .zshrc if you use zsh file (or each time you start a terminal at the command line).
Since Xcode hard coded its own version of git which is installed on /Applications/Xcode.app/Contents/Developer/usr/bin/git, I managed to use this work around trick:
change into the Xcode directory:
cd /Applications/Xcode.app/Contents/Developer/usr/bin
rename the Xcode's git like this:
sudo mv ./git ./git-xcode-usr-bin
link my own git which is installed through homebrew:
sudo ln -s /usr/local/bin/git ./git
And I did the same thing with /usr/bin/git
This will acctually link /usr/local/Cellar/git/1.8.0/bin/git (because I'm use git 1.8.0 at the present)
Certainly this may cause some other problems, such as when I upgrade the homebrew's verion git in the future, it would not work for me :( and I have to make a new link then.
I do it like this because I want to solve my own problem here 13177203. And after search StackOverFlow for a long time, I finally got this solution.
If you are using fish shell instead of bash, you can point to your preferred git binary by adding the following to ~/.config/fish/config.fish.
function git
/usr/local/bin/git $argv;
end

Resources