Using Git 2.x - Windows

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

The latest version of SourceTree supports Git 2.6.x as embedded git without the need of this guide.

問題

SourceTree for Windows currently embeds v1.9.5 of Git, but in principal can use any version of Git, 32-bit or 64-bit, as System Git, that can be found.

SourceTree 'finds' System Git installations by searching for git.exe in the following locations.

  1. searching the folders defined by the PATH environment variable.
  2. searching the program files folders
    1. c:\program files\
      1. Contains all programs on a 32-bit OS or all 64-bit programs on a 64-bit OS.
    2. c:\program files (x86)
      1. Contains all 32-bit programs on a 64-bit OS.

For the first git.exe it finds it will extract a Git System Path by stepping up its parent folders, for example

 Directory of C:\Program Files (x86)\Git\bin

01/05/2015  00:56         1,504,256 git.exe

gives a Git System Path of

C:\Program Files (x86)\Git

原因

SourceTree assumes the git.exe will be located in the bin folder within any installation it finds.

For the following Git System Path 

C:\Program Files\Git

SourceTree will attempt to run git.exe from

C:\Program Files\Git\bin\git.exe

However Git v2.x does not include a bin folder, only cmd

 Directory of C:\Program Files\Git

12/05/2015  09:59    <DIR>          .
12/05/2015  09:59    <DIR>          ..
12/05/2015  09:06    <DIR>          cmd
12/05/2015  08:54    <DIR>          dev
12/05/2015  09:07    <DIR>          etc
07/05/2015  16:14           136,192 git-bash.exe
07/05/2015  16:14           135,680 git-cmd.exe
12/05/2015  08:51    <DIR>          mingw64
06/05/2015  09:39            38,702 ReleaseNotes.html
12/05/2015  09:07    <DIR>          tmp
12/05/2015  09:07         3,584,926 unins000.dat
12/05/2015  09:04         1,299,217 unins000.exe
12/05/2015  08:51    <DIR>          usr

Therefore SourceTree fails to detect and use Git v2.x installations.

回避策

Use a SymLink to re-create the Git bin folder.

C:\Program Files\Git>mklink /D bin cmd
symbolic link created for bin <<===>> cmd

SourceTree can now find git.exe via the bin folder.

 Directory of C:\Program Files\Git

12/05/2015  09:59    <DIR>          .
12/05/2015  09:59    <DIR>          ..
12/05/2015  09:59    <SYMLINKD>     bin [cmd]
12/05/2015  09:06    <DIR>          cmd
12/05/2015  08:54    <DIR>          dev
12/05/2015  09:07    <DIR>          etc
07/05/2015  16:14           136,192 git-bash.exe
07/05/2015  16:14           135,680 git-cmd.exe
12/05/2015  08:51    <DIR>          mingw64
06/05/2015  09:39            38,702 ReleaseNotes.html
12/05/2015  09:07    <DIR>          tmp
12/05/2015  09:07         3,584,926 unins000.dat
12/05/2015  09:04         1,299,217 unins000.exe
12/05/2015  08:51    <DIR>          usr


最終更新日: 2016 年 2 月 26 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.