问题
Environment: Mac OSX 10.10. When I was trying to use gitk
, it shows:
Coda-2:~ Coda$ gitk
-bash: gitk: command not found
I think the reason is the old version of git
. Here is some information, and I have already typed brew update
.
Coda-2:~ Coda$ git --version
git version 1.9.3 (Apple Git-50)
Coda-2:~ Coda$ brew install git
Warning: git-2.4.0 already installed, it's just not linked
What is this message: it's just not linked
?
Furthermore, I check the path of git
:
Coda-2:~ Coda$ which git
/usr/bin/git
It should be in /usr/bin/local/git
? How to fix it?
UPDATE
I figure it out, thank @TimCastelijns.
brew doctor
said:
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
git
So, I typed:
Coda-2:~ Coda$ brew link git
Linking /usr/local/Cellar/git/2.4.0... 220 symlinks created
Then I typed gitk
, and it worked and the path changed to /usr/local/bin/git
. However, when I want to check the version of git
. It still showed the old version, why?
Coda-2:~ Coda$ git --version
git version 1.9.3 (Apple Git-50)
回答1:
First, check git
version.
Type git --version
, and it may show old version.
Next, update your Homebrew
Type brew update
.
Then, download the latest version. brew install git
Note that, if it show Warning: git-2.4.0 already installed, it's just not linked
We can check brew doctor
, in my case, it told me to use brew link git
Finally, type brew install git
again and restart terminal.
I can use gitk
and upgrade git version to the latest version.
Update
Since gitx
is no longer supported for OSX 10.12
, I recommend using Gitx-dev
回答2:
Granted the OP is using Mac, a Linux user will find this link from Google and the accepted solution will not help.
On Linux, use your favourite package manager and install git-gui
.
On RedHat-based systems, ex CentOS, do:
yum install -y git-gui
which will install the gitk
dependency.
Done.
来源:https://stackoverflow.com/questions/30195143/gitk-command-not-found