Опасен ли параметр «Использовать Git и дополнительные инструменты Unix из командной строки Windows»?

8603
Aleksandr Dubinsky

При установке Git, он предлагает возможность добавить все свои инструменты msys * nix в вашу PATH, однако предупреждает:

Предупреждение: это переопределит инструменты Windows, такие как «найти» и «сортировать». Используйте эту опцию, только если вы понимаете последствия.

Мои вопросы:

  • С какими инструментами он будет конфликтовать?
  • Это имеет значение? Они обычно используются системой? (Я никогда не использовал их лично.)
  • Могу ли я просто изменить порядок каталогов в PATH, чтобы предотвратить конфликты?
  • Это то, что делает второй вариант? («Использовать Git из командной строки Windows - этот параметр считается безопасным, поскольку он добавляет только некоторые минимальные оболочки Git»)
9

2 ответа на вопрос

7
Anaksunaman

Which tools exactly will it conflict with?

Personally I am unsure of a full list, but this StackOverflow question says

"This includes find, kill and sort [...] The problem with the first 3 (and similar) is that they exist in both OSs and function differently in each."

They may not be used often by you but are common enough that Git feels the need to warn you about unexpected behavior.

Anecdotally, they are more likely to appear in third party programs (mostly scripts), so the level of effect most likely depends on how much you use programs that rely on any of those commands.

Is this what the 2nd option does? ("Use Git from the Windows Command Prompt -- This option is considered safe as it only adds some minimal Git wrappers")

Basically it allow you to use Git from the command line (cmd.exe) with all the common Git commands. This option is perfectly safe and useful for 99% of what you would likely want to script or manually implement from a Windows command line. I use this option and have never personally encountered any issues.

After you install, you may also want to look at a graphical git interface (such as GitHub Dekstop for Windows or SourceTree) and don't forget that Git bash comes with the installation as well.

На самом деле, я хотел бы использовать некоторые инструменты из CMD, и мне было интересно, если 2-й вариант делает какой-либо из инструментов Unix доступным или только git. Aleksandr Dubinsky 9 лет назад 0
Насколько мне известно, это только мерзавец. Anaksunaman 9 лет назад 0
3
RobertL

Which tools exactly will it conflict with?

I would let the install modify your PATH. It's easy to remove it from the PATH if you don't want it. Then I would look at the directories and do some comparisons like diff, comm, etc. to find out the conflicts. They should be documented somewhere though I don't know where.

Does it matter? Are they commonly used by the system? (I've never used them personally.)

I haven't used the cygwin tools lately, but when I had to use Windows, I commonly had the cygwin tools directory first in my PATH without problems.

The biggest risk would be if a program was looking for the conflicting Windows command line tools, it would execute the incorrect program. I think the chances of this are very slim, considering the extremely small amount of cmd.exe scripting that goes on.

Can I just change the order of the directories in the PATH to prevent conflicts?

Yes. Just move the cygwin, or whatever git adds, to the end of the PATH. Just remember that certain command sequences won't work correctly in cygwin. Also, come to think of it, I think the cygwin console sets up the path correctly. Setting up your own path when you use cygwin would then make cygwin operate correctly also.

Is this what the 2nd option does? ("Use Git from the Windows Command Prompt -- This option is considered safe as it only adds some minimal Git wrappers")

It sounds as if this would insert to the PATH a directory containing only the git commands that you need to use git.

На самом деле, Git использует MSYS вместо Cygwin. Разница в том, что msys является родным win32, а cygwin использует библиотеку эмуляции для адаптации кода posix. Aleksandr Dubinsky 9 лет назад 0

Похожие вопросы