677

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, same thing.

I found this article on a similar issue with Git on Mac OSX, which leads me to believe that it has something to do with a faulty PATH, but I'm still pretty new at all this (5 months self-taught), so I'm at a loss in how to translate this to Windows.

This problem arose when I began a new 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.

Basil
  • 1,240
  • 10
  • 17
BrianScottK
  • 6,879
  • 3
  • 11
  • 7
  • 1
    For all the headaches it solves, Git never fails to provide its own. Look at all these upvotes. This shouldn't be a thing. – Kyle Vassella Jun 25 '20 at 19:20

19 Answers19

1400

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
Naman
  • 23,555
  • 22
  • 173
  • 290
Dutch Glory
  • 14,795
  • 1
  • 12
  • 6
  • 4
    > git update in version 2.14 didn't work for me (on windows). I used the installer downloaded from the website and everything went smooth (now on 2.17.1) – gianni May 31 '18 at 08:16
  • 3
    I think it's being downvoted because the version where these commands work are more specific than originally specified. `git update` doesn't work until 2.14.2, which means for people like @defines above, this answer looks wrong. – rickibarnes Aug 15 '18 at 01:33
  • 3
    I think I have to uninstall my _Git for Windows_ and reinstall the newest version, because the version I'm using is _git version 2.14.1.windows.1_. – KaiserKatze Sep 21 '18 at 13:39
  • 1
    I am on version 2.9.0 and none of the commands work for me. Can you please help me with how to do it? – Nirmal Dalmia Nov 20 '18 at 13:50
  • Worked perfectly for me as well. Just clicked "Next" for each of the steps, and since they defaulted to the currently-set values, it didn't change my config at all. – Venryx Oct 17 '19 at 01:20
  • `git update-git-for-windows -y` _Git for Windows 2.21.0.windows.1 (64bit) Update is available Downloading curl: no URL specified! curl: try 'curl --help' or 'curl --manual' for more information_ I am seeing above response hence unable to get update. My current git version is 2.21.0 – Vishwak Dec 02 '19 at 09:06
  • 1
    If the new version downloads but doesn't run the installer, try running the Windows Command Prompt "as administrator." Once I did that update-git-for-windows worked great. – kenswdev Dec 14 '19 at 16:39
  • Just some history as I was searching for the cmd: 2.14.1 introduced the update cmd "*Comes with a new custom Git command git update to help keeping Git up-to-date on your machine*" and 2.16.1 changed the name: "*The git update command has been renamed to git update-git-for-windows to avoid confusion where users may think that git update updates their local repository or worktree*" https://github.com/git-for-windows/build-extra/blob/master/ReleaseNotes.md – JohnGoldsmith Feb 06 '20 at 09:48
  • `git update` still works for me in git 2.25.01, albeit with a warning that the command is depreciated. – toonarmycaptain Apr 03 '20 at 23:36
  • please remove that c:\> as, we lazy folks like to copy paste directly without changing anything – PAS Jun 10 '20 at 17:33
  • `git update-git-for-windows` didn't work for me on the work laptop since the corporate firewall was replacing the cert with their own self-signed one, which results in "curl: (60) SSL certificate problem: self signed certificate in certificate chain" error. I ended up just downloading from the official site and the upgrade ran without a hitch. – thdoan Oct 28 '20 at 18:16
191

First, check your git version by using this command

git version

Then follow the case according to your git version

Three cases:

  1. If your git version is 2.14.1 or earlier:

    Uninstall the git, download the latest git, and install it again.

  2. And versions between 2.14.2 and 2.16.1:

    Use command git update

  3. If the version is equal to or greater than Git 2.16.1(2):

    Use command git update-git-for-windows

AlexC
  • 3,391
  • 3
  • 23
  • 25
Arslan Ahmad khan
  • 3,648
  • 1
  • 21
  • 31
  • 6
    I was going crazy with `git update` error on 2.14.1 version. So this answer is the right answer since it addresses that inexistente command before 2.14.2. – Erick Petrucelli Sep 11 '19 at 14:58
  • 5
    Uninstalling older version is not needed. You can install the new version upon older version. It worked for me – Deekshith Hegde Jun 17 '20 at 17:28
50

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.

enter image description here

Once the files are dowloaded, Continue with 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.

enter image description here

Basil
  • 1,240
  • 10
  • 17
  • 9
    How is this different from answers already provided? Simply attaching a screenshot does not add *anything* in this case. Part of the strength of SO is that good answers are upvoted, rather than duplicated, which simply clutters the page and hinders users' ability to find solutions to issues. This is quite different from forums, which have their own strengths. Please review https://stackoverflow.com/help to learn how the SO platform, & how it differs from other platforms. Ironically, you advocated for removal of another Q that did the same as you did here. There're plenty of ways to contribute. – SherylHohman Jul 28 '20 at 18:27
  • 2
    thanks for the screenshot though. It helps me that I am on the same page and not doing anything wrong. – Santosh Dec 30 '20 at 18:03
41

Update (26SEP2016): It is no longer needed to uninstall your previous version of git to upgraded it to the latest; the installer package found at git win download site takes care of all. Just follow the prompts. For additional information follow instructions at installing and upgrading git.

David
  • 934
  • 10
  • 12
  • 10
    It is not that installer "takes care of everything", it simply overwrite the previous install. So if there are custom setting, there will be overwritten! – Celdor Apr 03 '17 at 07:48
  • 5
    Is there a way to upgrade and keep my existing settings? when I run the windows installer to do the upgrade, it asks me all the same complicated questions it asked when I first installed (about line endings, editor preferences etc.). What I really want is to just get the new version and keep all my existing settings – Andy Apr 04 '18 at 09:56
  • @Andy, I am not sure if it will cover every setting, but I would use the git-config command prior to upgrading, store your values in a script, upgrade with default settings and then use the script to customize your settings. Reference: https://git-scm.com/docs/git-config – David Apr 04 '18 at 18:28
  • 4
    The installer does not overwrite any settings, and all settings you can choose in the install default to their current values. – OrangeDog May 03 '18 at 12:51
28

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 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 (except for telling you that it's doing the right thing 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

Community
  • 1
  • 1
SherylHohman
  • 12,507
  • 16
  • 70
  • 78
23

Just run:

$ git update-git-for-windows
Soroush Chehresa
  • 3,630
  • 1
  • 10
  • 23
moriarty007
  • 1,712
  • 10
  • 17
18

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.)

Rajan Ponnappan
  • 304
  • 2
  • 8
18

Update Git Through Command Prompt

  1. Check Version git --version

  2. If your git version is 2.27.0.windows.1 or earlier

  3. If the version is equal to or greater than Git 2.27.0.windows.1

  4. Use command git update-git-for-windows

if you want to video tutorial click here

Azmat Ali
  • 368
  • 2
  • 7
10

You can use,

git update

Or if you are on a Windows machine, you can run the command below,

git update-git-for-windows
Jaied
  • 181
  • 1
  • 7
7

Based on the last response from @Simon, 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 rails terminal window shows that I am running the new git version 1.8.0.

BrianScottK
  • 6,879
  • 3
  • 11
  • 7
5

If someone checking in 2021, this works fine;

git update-git-for-windows

This will download the latest version of git. After that a window will open which asks for installing new version of git. Install that and you are done. To check the version of the git on your computer;

git --version
Irfan wani
  • 1,474
  • 2
  • 6
  • 17
4

if you just type

$ git update

on bash git will inform you that 'update' command is no longer working and will display the correct command which is 'update-git-for-windows'

but still the update will continue you just have to press " y "

if you are having issues on it run the bash as administrator or add the 'git.exe' path to the "allowed apps through controlled folder access".

ailia
  • 161
  • 1
  • 7
3

to check out your PATH variable, act as follow:

  1. From the Desktop, right-click My Computer and click Properties.
  2. Click Advanced System Settings link in the left column.
  3. 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.

ΩmegaMan
  • 22,885
  • 8
  • 76
  • 94
Simon Boudrias
  • 38,416
  • 12
  • 90
  • 126
  • Thanks for the help, @Simon, but I'm still having problems. I was able to locate the `Path` row in my Environment Variables. You were correct in that it was directing to what seems to be an older version of Git. (Apparently, I have 2 versions. My original as installed via RailsInstaller located in the RailsInstaller directory, and the new one that I just installed in its own directory.) My `Path` row read `C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby1.9.3\bin` and based on your response, I changed it to `C:\Git;C:\RailsInstaller\Ruby1.9.3\bin`, but my terminal is still showing v 1.7.9... – BrianScottK Dec 09 '12 at 19:59
  • Have you open a new command prompt after the change to check the version? Also, in `C:\Git`, you should have a git Bash, open it and checkout you have the right version in this bash, this will confirm this folder is where 1.8 is really installed. If nothing does it, try to uninstall the old version and reinstall the new one. – Simon Boudrias Dec 09 '12 at 20:12
  • Thanks, @Simon! This didnt work exactly, but led me to the right answer, which I have outlined below. Appreciate the help! – BrianScottK Dec 09 '12 at 21:00
  • 1
    A quicker way to get a list of paths is to open Powershell and enter the following: `$env:path -split ';'` – Dave Sexton Mar 09 '18 at 14:20
  • You can use `where git` to see where Git is installed. Make sure that path is in your `PATH`. I like @DaveSexton method above for viewing the PATH var. Is there a way to get a similar list from a Git Bash window, rather than Powershell? – SherylHohman Jul 26 '19 at 16:06
3

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.

colidyre
  • 3,035
  • 11
  • 30
  • 43
Nate
  • 33
  • 3
  • Okay, false alarm. The update shows as "done," however, the version shows as the same, so I uninstalled and downloaded the newest version of Git. – Nate Feb 16 '20 at 21:57
3

If it is Windows, you can simply hit below command to update git. -

git update-git-for-windows
2

I don't think your problem is related to Windows global PATH, as remote is specific to repo.

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 less error.

All you need is to type bash in Window CMD 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 Rails and Ruby. I used RailsInstaller before, but 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). Windows is not very friendly to every Unix tools ultimately. You'll find all pain stopped.

Billy Chan
  • 23,554
  • 4
  • 48
  • 66
  • I've heard other people suggest this, but right now I feel I'm just too new to notice a difference in Cygwin vs Windows CMD. – BrianScottK Dec 18 '12 at 02:54
  • 1
    Cygwin will mimic unix enviroment. All commands will look like native, and the enviroment vairables for unix will be in one place - under cygwin folder. If you are not prepared to linux, use cgywin at least. – Billy Chan Dec 18 '12 at 03:08
  • 2
    Cygwin sucks, it's very bloated and there are loads of surprising and broken behaviors. If you want to use Git on Windows then you should definitly use Git for Windows - it even provides a native Windows bash and some *NIX tools. If you really want a full Linux environment on Windows, then go to the Microsoft Store and install one of them (Ubuntu, SUSE, Debian, Kali). – OrangeDog May 03 '18 at 12:49
0

If you have already installed git , you can update the git with the command git update-git-for-windows

to know the current version use git --version

you can run this commands in cmd prompt

Rohan Devaki
  • 898
  • 4
  • 12
  • How is this different from answers already provided? Part of the strength of SO is that good answers are upvoted, rather than duplicated with new answers which simply clutters the post, and hinders users ability to find *solutions* to issues. This is quite different from forums, which have their own strengths.. Please review https://stackoverflow.com/help and learn about the SO platform, how it works, and how it differs from other platforms. – SherylHohman Jul 28 '20 at 17:54
  • it is simple and short , as compared to other answers, as well as it works also, what else do you want?. – Rohan Devaki Jul 29 '20 at 12:26
  • I get the error: `git: 'update-git-for-windows' is not a git command. See 'git --help'.` – alizeyn Aug 09 '20 at 07:36
  • make sure you are in one of the user directory, like it should be ```C:\Users\Rohan>``` or else try ```git update``` (i know it is deprecated and older version) but it will show you a command for update of git like, for me it showed ```git update-git-for-windows```. – Rohan Devaki Aug 09 '20 at 13:06
0

05 2021

The question is still active so I am providing a little more information to it.

I think everyone has given enough answer to check git version. Here's a handy table to check your version current legend.

Legend Version
Old version 0.99 (Jul 2005) - 2.16 (Jan 2018)
Older version, still maintained 2.17 (Apr 2018) - 2.30 (Dec 2020)
Latest version 2.31 (Mar 2021)

Src: https://en.wikipedia.org/wiki/Git

Dexter
  • 3,590
  • 1
  • 23
  • 24
-6

If you are using MacOS

To check the version

git --version

To Upgrade the version

brew upgrade git
double-beep
  • 3,889
  • 12
  • 24
  • 35
scorpiopd
  • 1
  • 2
  • 2
    The question clearly states that it is in regards to the windows operating system. This answer is not very relevant to the question. Anyone using MacOS will never be able to reach this answer. In my opinion, this answer should be removed. – Ayushya Jul 18 '20 at 12:57
  • 1
    @Ayushya While the OP did ask for the MAC OS, future visitors often land on these old answers from search engines. When they cannot find answers for the correct operating system, it's sometimes helpful to be pointed in the correct direction, via comments, or an answer explicitly stating the variance. This one is at best a gray area, as the answer is definitely OS specific, though it's still a similar solution. It's better when the answer is only a slight variation, such as when care must be taken for `/` vs `\\` or spaces in a *command*, rather than a different eco system for installs/updates. – SherylHohman Jul 28 '20 at 18:08