问题
I was using msysgit and git-bash in cmder when I accidentally exited out of it.
Now I can't seem to figure out how to get to the unix environment I previously had.
Git bash is not recognized as a command.
All I see is the typical command window prompt displaying the C:/User/..
rather than the $~User
.
How would you restore the git bash session?
回答1:
You can type the full path of your msysgit intallation (2014, Git 1.9.z) to launch a bash session.
For instance:
"c:\prgs\git\PortableGit-1.9.0-preview20140217\Git Bash.vbs"
: will open a new windows"c:\prgs\git\PortableGit-1.9.0-preview20140217\git-bash.bat"
: will open a bash session within the current shell.
Those two scripts aren't part of <msysgit/bin>
folder, and are not found in %PATH%
.
As commented by David Grayson and pred below in the comments, using Git-1.9.5-preview20141217.exe does result in an installation (in C:\Program File) which does not have git-bash.bat, and which rely on "Git Bash" shortcut calling C:\Git\bin\sh.exe --login -i
.
Don't use that setup. Use the much easier and more complete package PortableGit-1.9.5-preview20141217.7z that you unzip anywhere you want and that you add to your PATH.
Note: with the new Git for Windows releases (2015, Git 2.y.z), that would be:
- "
c:\prgs\git\PortableGit-2.3.5.8-dev-preview-64-bit\git-bash.exe
": will open a bash session within the current shell.
回答2:
An easy way to get this working is to define a custom "bash" task in Cmder, and then configure it to use this task by default.
- Install cmder_mini (msysgit is already installed, so no need for full version)
- In Cmder, open settings:
Win + Alt + P
- Under Startup > Tasks, add a task called
{bash}
with the following settings:- Task parameters - set the icon:
- Either
/icon "%CMDER_ROOT%\cmder.exe"
(for Cmder icon) or/icon "C:\Program Files (x86)\Git\etc\git.ico"
(for Git icon)
- Either
- Commands - open Git's bash shell:
"C:\Program Files (x86)\Git\bin\sh.exe" -l -new_console:d:%USERPROFILE%
- Task parameters - set the icon:
- Under Startup, set startup options to Specified name task --> {bash}
...this will set Git bash as the default console in Cmder.
nb. The above obviously assumes that Git is installed in "C:\Program Files (x86)\Git" - if that's not the case, you'll need to change the path to point to wherever Git is installed.
回答3:
Run the following command in cmder:
sh -l
This assumes that Git's "sh" is on your PATH. But if you installed git differently and sh is not found, then try entering the full path to it, for example:
"C:\Program Files (x86)\Git\bin\sh.exe" -l
If you want to automate this so you don't have to run sh explicitly, then go into cmder/ConEmu's settings and change the {cmd} task to have the command sh -l
and the parameters /dir "%HOME%"
. Then cmder will always start up Git Bash by default, instead of Microsoft's cmd shell.
来源:https://stackoverflow.com/questions/25107769/how-do-i-run-msysgit-in-cmder