如何在 Windows 上升级到最新版本的 Git?仍然显示旧版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13790592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to upgrade to the latest version of Git on Windows? Still showing older version
提问by BrianScottK
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 siteand installed through the normal Git installer EXE.
我刚刚从我之前的版本 1.7.9.mysysgit.0 升级到适用于 Windows 的 Git 1.8.0.1。我从 Git 站点下载了新版本并通过普通的 Git 安装程序 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.
也就是说,当我启动终端窗口时,它仍然显示我正在运行 git 版本 1.7.9.mysysgit.0。当我从提示中输入“git --version”时,同样的事情。
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.
我发现这篇关于 Mac OSX 上 Git 的类似问题的文章,这让我相信它与错误的 PATH 有关,但我对这一切仍然很陌生(5 个月自学),所以我不知道如何将其转换为 Windows。
This problem arose when I began a new Rails project and tried to push it up to Git. I added the remote:
当我开始一个新的 Rails 项目并试图将它推送到 Git 时,这个问题就出现了。我添加了遥控器:
git remote add origin [email protected]:brianscottk/blog.git
then:
然后:
git push -u origin master
I received the following error message:
我收到以下错误消息:
fatal: https://github.comrefs not found: did you run git update-server-info on the server?
致命:找不到https://github.comrefs:您是否在服务器上运行了 git update-server-info?
Googling that error led me to this article, which prompted me to upgrade, and here I am.
谷歌搜索那个错误让我看到了这篇文章,这促使我升级,我在这里。
回答by Dutch Glory
Since Git 2.16.1(2) you can use
由于 Git 2.16.1(2) 你可以使用
C:\> git update-git-for-windows
In versions between 2.14.2 and 2.16.1, the command was
在 2.14.2 和 2.16.1 之间的版本中,命令是
C:\> git update
(It was later renamed to avoid confusion with updating the local repository, e.g. like svn update
does it.)
(它后来被重命名以避免与更新本地存储库混淆,例如像svn update
这样。)
That command does not exist in Git 2.13 and before.
该命令在 Git 2.13 及之前版本中不存在。
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.
如果出现“不是 git 命令”的错误,那么要么您实际上没有 Windows 版 Git,要么您的版本很旧。
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.
在这种情况下,只需从https://git-scm.com/download获取最新的安装程序(检查您想要 32 位还是 64 位)并运行它来升级。
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
回答by Arslan Ahmad
First, check your git version by using this command
首先,使用此命令检查您的 git 版本
git version
Then follow the case according to your git version
然后根据你的git版本按照case
Three cases:
三种情况:
If your git version is 2.14.1 or earlier:
Uninstall the 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 版本是 2.14.1 或更早:
卸载 git,下载最新的git,然后重新安装。
以及 2.14.2 和 2.16.1 之间的版本:
使用命令
git update
如果版本等于或大于 Git 2.16.1(2):
使用命令
git update-git-for-windows
回答by David
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 sitetakes care of all. Just follow the prompts. For additional information follow instructions at installing and upgrading git.
更新(26SEP2016):不再需要卸载之前版本的git升级到最新版本;在git win 下载站点上找到的安装程序包会处理所有问题。只需按照提示操作即可。有关其他信息,请按照安装和升级 git 的说明进行操作。
回答by Rajan Ponnappan
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.
使用命令“where git”找出命令提示符如何获取版本。获得路径后,您可以继续完全卸载/删除以前的版本。然后,如果您安装并确保新安装的位置在路径中,它应该可以正常工作。
Using git-friendly tools like cmderwill 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.)
使用像cmder这样的git友好工具会让你的生活更轻松。您真的不必再使用双启动或 cygwin,因为 Windows 中对 git 的支持现在已经是一流的了。(Windows 版 Git 安装了 msysgit,其中包括来自 MinGW 的所有必要的 unix 工具。MinGW 已经存在一段时间并且非常稳定。如果您愿意,您可以安装完整版的 msysgit 而不是Windows版的 Git。msysgit在 Git 上可用于windows页面在底部。)
回答by moriarty007
Just run:
赶紧跑:
$ git update-git-for-windows
回答by SherylHohman
Git Bash
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
.
请注意,如果您Git Bash
想查看正在运行的版本,或者想查看是否需要更新Git Bash
,则它是Git for Windows
.
So your Git Bash version is:
所以你的 Git Bash 版本是:
git --version
git version 2.23.0.windows.1
git 版本 2.23.0.windows.1
Note that it is technically different from Bash
. On my same machine when I run:
请注意,它在技术上与Bash
. 在我运行的同一台机器上:
echo $BASH_VERSION
4.4.23(1)-release
4.4.23(1)-发布
Git for Windows installer
适用于 Windows 的 Git 安装程序
To update to the latest version of Git and Git Bash, you can downloadand 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.
要更新到最新版本的 Git 和 Git Bash,您可以下载并安装最新版本的git for Windows。根据FAQ,如果设置/自定义安装在适当的配置文件夹中,则应保留它们。
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 subsequentsettings screens to you. Only screens with newly introduced settings will be shown.
事实上,他们让事情变得更容易(如果他们这样做是很清楚的话)。
底部有一个复选框[] Show only new settings
(我不记得确切的措辞)。由于当您标记该框时,第一个屏幕上的任何内容都不会改变,因此它的用途并不十分明显。如果您选中该框,则将保留您当前的所有设置,并且将跳过向您显示这些后续设置屏幕。只会显示具有新引入的设置的屏幕。
git update-git-for-windows
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 Bash 命令行更新 Git Bash 和 Git(根据定义,两者总是同时更新):
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
:
如果您键入git update
,git 会提醒您该命令已更新为git update-git-for-windows
:
Warning!
git update
has been deprecated;
Please usegit update-git-for-windows
instead.
Git for Windows 2.26.0.windows.1 (64bit)
Up to date
警告!
git update
已被弃用;
请git update-git-for-windows
改用。
Git for Windows 2.26.0.windows.1 (64bit)
最新
回答by BrianScottK
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
.
根据@Simon 的最后回复,我首先卸载了新版本的 Git。我然后重新安装的Git的新版本到相同的目录旧版本,C:/RailsInstaller/Git
的,而不是默认的目录C:/Git
。
Now my rails terminal window shows that I am running the new git version 1.8.0.
现在我的 rails 终端窗口显示我正在运行新的 git 版本 1.8.0。
回答by Simon Boudrias
to check out your PATH
variable, act as follow:
要检查您的PATH
变量,请执行以下操作:
- From the Desktop, right-click My Computer and click Properties.
- Click 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)
到达那里后,滚动以获取该Path
行,您将获得一长串路径(例如C:\windows\bin;C:\program files\git
,等)
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.
找到git
被引用的一行或多行。然后,确保此路径指向您的 Git 1.8.x 安装。如果没有,删除它并添加最新 Git 版本的真实路径。最后,链接到 Git 的字符串中应该只有一个路径。
Hope this help!
希望这有帮助!
回答by ailia
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'
在 bash 上,git 会通知您“update”命令不再有效,并将显示正确的命令“update-git-for-windows”
but still the update will continue you just have to press " y "
但更新仍会继续,您只需按“ y ”
if you are having issues on it run the bashh as administrator or add the 'git.exe' path to the "allowed apps through controlled folder access".
如果您遇到问题,请以管理员身份运行 bashh 或将“git.exe”路径添加到“通过受控文件夹访问允许的应用程序”。
回答by Nate
If you look at the most recent update on Git's websitein the "git via git"section you will see an option to update your older version.
如果您查看Git 网站上“通过 git 进行 git”部分的最新更新,您将看到一个更新旧版本的选项。
Here is the command that git has on their site:
这是 git 在他们网站上的命令:
git clone https://github.com/git/git
It worked for my version of git which was a 2.13.0.windows.1
.
它适用于我的 git 版本,它是一个2.13.0.windows.1
.