为什么“ MINGW64”出现在我的 Git bash 中?

我必须格式化我的笔记本电脑,所以我必须再次安装 Git。但是它和我昨天的那个有很大的不同,这个图标不再是默认的橙色的了,它现在看起来更像 Chrome 了。

git

bash是非常不同的,包括一个紫色的“ MINGW64”在每一行。为什么它在那里?

这是新的最终版本吗? 还是我下载了一些不同的东西?

我从 https://git-scm.com/downloads下载了 https://github.com/git-for-windows/git/releases/download/v2.5.1.windows.1/Git-2.5.1-64-bit.exe

谢谢!

98636 次浏览

This is the new icon being used with Git for Windows 2.x. The website needs an update for that I guess but there are not many volunteers typically.

The MINGW64 is the value from the MSYSTEM environment variable. This has been included in the bash prompt by setting PS1 in the /etc/bash.bashrc file. You can either override this in your own $HOME/.profile or edit the distributed one to remove that if you prefer.

Easiest way to remove 'MINGW64' is to comment two lines in file:

\Git\etc\profile.d\git-prompt.sh
...
# PS1="$PS1"'\[\033[35m\]'       # change to purple
# PS1="$PS1"'$MSYSTEM '          # show MSYSTEM

I just noticed this on my machine as well. The orange icon you're referring to is probably the Ubuntu icon you would normally get while running the "Bash on Ubuntu on Windows" app. However, when you installed GIT, it also uses a version of bash. The app is called "Git Bash" in the start menu.

When I simply typed "Bash" in the search box and then and pressed enter, Windows opened the "best match", which happens (in my case) to be GIT installation with MINGW64. If you type "Ubuntu" instead, or if you look at the start menu's choices, you should see the other bash.

This is important to know that the two environments are separate, since programs from one environment may not be installed in the other.

MINGW64 is 'Minimum GNU for Windows 64 bit'. It's the name of a compiler used to build an extra copy of bash that "git for Windows" includes.

"Git for Windows" includes git plus a variety of additional software, which you may already have on your machine. This includes:

As PS1 tastes are generally personal you may prefer your existing setup.

If you want git, but don't want all the extra software

  • You can get a minimal build from nuget if you don't have any git apps installed.

  • But if you use a GUI that may also include an embedded git - personally I use the one included with Sourcetree. In my powershell profile:

    Add-PathVariable "${env:UserProfile}\AppData\Local\Atlassian\SourceTree\git_local\bin"

This provides git without any additional changes to your system or extra copies of other software.

(Add-Pathvariable comes from PSCX by the way)

It's a little different in the new git versions.

  • copy the line below in /etc/bash.bashrc: export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[35m\]$MSYSTEM\[\e[0m\] \[\e[33m\]\w\[\e[0m\]\n'"${_ps1_symbol}"' '

  • add it to ~/.bashrc and do some custom edit: export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n '

    If you do not like the additional blank line when press Enter, just remove the \n above.

  • source the ~/.bashrc file: source ~/.bashrc

  • my terminal example:

    enter image description here

export PS1="${PS1/\$TITLEPREFIX:}"; export PS1="${PS1/\$MSYSTEM }" >> ~/.bashrc

As stated by @patthoyts

MINGW64 is the new icon being used with Git for Windows 2.x. The MINGW64 is the value from the MSYSTEM environment variable. This has been included in the bash prompt by setting PS1 in the /etc/bash.bashrc file. You can either override this in your own $HOME/.profile or edit the distributed one to remove that if you prefer.

MINGW64 and the name of the system is something that we don't want to or need to see always and sometimes may want to remove them for effective use of display space. To do that, we just need to comment out 4 lines in \Git\etc\profile.d\git-prompt.sh which is typically inside your program files.

PS1="$PS1"'\[\033[32m\]'       # change to green
PS1="$PS1"'\u@\h '             # user@host<space>
PS1="$PS1"'\[\033[35m\]'       # change to purple
PS1="$PS1"'$MSYSTEM '          # show MSYSTEM

These are the 4 lines in git-prompt.sh, typically line number 14 to 17, that can be commented out by placing # at the start of each line to remove computer name shown in green and MSYSTEM shown in purple. If you just want to remove one of these, you can comment lines accordingly. It should look similar to this

# PS1="$PS1"'\[\033[32m\]'       # change to green
# PS1="$PS1"'\u@\h '             # user@host<space>
# PS1="$PS1"'\[\033[35m\]'       # change to purple
# PS1="$PS1"'$MSYSTEM '          # show MSYSTEM

The easiest way is to use:

$ parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'; }
$ export PS1="\u@ \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

Just a small addition. If Windows is installed on C Drive, then this is the path to edit the file git-prompt.sh and comment out the desired lines (usually 14-17):

C:\Program Files\Git\etc\profile.d