issue with Git Bash - bash

I am able to open git bash by typing "git bash" in the windows explorer URL space on one of my other laptop.
However, I'm trying to do it on another laptop of mine and it refuses to work. A black terminal opens for a split second and then disappears.
I've reinstalled it multiple times to no avail.
Currently using v2.27 of Git on Windows 10.
Any idea how I can get this working again? It's super convenient for me.

In system variables the C:\Program Files\Git\cmd is added to Path.
To launch git-bash.exe (which is the program which will use git.exe internally)
directly from windows explorer address field, you need to make it findable in Path.
git-bash.exe is in C:\Program Files\Git\ (notice the lack of cmd directory)

Related

How to change from MinTTY to Windows 10 default console in Git Bash?

I am using Windows 10.
I have Git Bash (from Git 2.20.1) installed with configuration of using MinTTY as terminal emulator.
I can see that following entry in Git-2.20.1/etc/install-options.txt
Bash Terminal Option: MinTT
This means when I start git-bash it uses MinTTY as terminal - one can see this by right clicking on the title bar of git-bash window.
Now I have to switch to windows default console. When I say "switch" I mean when I start git-bash I expect it to use windows console - I should be able to confirm this by right clicking on the title bar of git-bash window.
Below link explains the difference between MinTTY and Windows console - https://willi.am/blog/2016/08/08/docker-for-windows-interactive-sessions-in-mintty-git-bash/
However I cant find any config or mechanism to change this. (Changing install-options.txt with Bash Terminal Option: ConHost does not have any effect)
And I cant reinstall it as it has came via my organizations packaging system.
Is there any config anyone knows which I am missing?
Appreciate help - Many Thanks !
This switch is a part of git-bash.exe binary. It's only being edited by Git Windows installer hook named edit-git-bash.
You could compile and run edit-git-bash.
Or reinstall Git entirely (simpler)

Have WSL shell open to project directory in Windows Visual Studio Code

I have a windows subsystem for Linux Installed on my computer and am using it as the integrated terminal on Visual Studio Code. Every time I open a terminal however, it opens in the root directory rather than the current project directory like other terminals do.
Does anyone know of a fix for this?
I have tried messing with the Cwd of the integrated terminal settings but haven't had any luck.
Try using wsl.exe as the command for shell.
"terminal.integrated.shell.windows": "wsl.exe"
I know that is very late for this answer, but for me it just worked.
I put exactly as above and it launched in my home directory (that is /mnt/d/Users/Adrian).
I have the user setup of VSC, 1.30.1 and launch it from the Desktop shortcut.
After I configured terminal as wsl I go as below:
If I open a cmd windows I can launch it with code . it will launch in Windows home directory.
If move to some other folder (e.g Documents) and launch it with code . the bash will launch to that folder.
Otherwise I can launch it with code D:\Users\Adrian\Documents\VSC and the bash terminal will launch in \mnt\D\Users\Adrian\Documents\VSC
Tested the change both via menu File->Preferences->Settings and with Ctrl+Shift+P (Command Pallete), Terminal: Default Shell.
Tried with bash and wsl.
Maybe you have some other bash installed in the path? (e.g. git bash or MinGW bash?)

Windows 10 cannot recognize Git

I have installed Windows 10 x64 on my laptop, and then go with latest Git as well (Git-2.6.3-64-bit). As I see on my laptop, Git now is installed at this directory: C:\Users\MyPC\AppData\Local\Programs\Git (I have no chance to specify another particular folder because it's done automatically during Git installation). The options "Use Git from the Windows Command Prompt" and "Use OpenSSH" are already selected, the windows path is updated with Git dir. And after all, the problem is, Windows cannot recognize where Git is to call. I've tried git --version but it's unrecognized from Windows.
My questions are (on Windows 10 Pro x64):
1. Can we specify another installation folder for Git?
2. In Git dir/bin, there no ssh.exe, while in OpenSSH selection dialog, it tells me "This uses ssh.exe that comes with Git". So where is it, the built-tin SSH client?
3. I'm doubting that now Windows 10 doesn't accept any external program installed on %USERPROFILE%/AppData to be included to system path. Is it correct?
4. How to make Windows "see" Git?
Just solved this myself this was a very frustrating journey but for me the following got me going:
Make sure c:\Windows\System32\OpenSSH\ is in your path variables (yea I know Windows should see this on its own)
Go to C:\Users\<>.gitconfig edit your global git config file to point to the correct ssh.exe 'C:/Windows/System32/OpenSSH
Make sure your id_rsa.ppk file is in C:\Users\<>.ssh If you don't have an SSH key yet generate one and make sure it ends up in this folder
You may also want to check that your OpenSSH Authentication Agent is started in Windows Services
Can we specify another installation folder for Git?
Try running the installer as an administrator, so it can be installed to Program Files. I'm not sure how to specify a custom path.
In Git dir/bin, there no ssh.exe, while in OpenSSH selection dialog, it tells me "This uses ssh.exe that comes with Git". So where is it, the built-tin SSH client?
Some digging told me that it might live inside the .ssh folder in the Git installation, so C:\Users\MyPC\AppData\Local\Programs\Git\.ssh
I'm doubting that now Windows 10 doesn't accept any external program installed on %USERPROFILE%/AppData to be included to system path. Is it correct?
AFAIK you can add any directory to your path.
How to make Windows "see" Git?
Add C:\Users\MyPC\AppData\Local\Programs\Git to your path:
Start the System Control Panel applet (Start - Settings - Control Panel - System).
Select the Advanced tab.
Click the Environment Variables button.
Under System Variables, select Path, then click Edit.
You'll see a list of folders, as this example for my system shows: C:\Program Files\Windows Resource Kits\Tools\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Support Tools\;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\Intel\DMIX;C:\Program Files\Executive Software\Diskeeper\;C:\Program Files\Bonjour\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Misc
You can add additional folders that you want to include in searches. I add a "C:\program files\misc" entry into which I place my standalone utilities, instead of copying them into C:\windows. Click OK.
You'll need to restart the processes (e.g., command prompt) that use the system path to see the added folders.
From http://windowsitpro.com/systems-management/how-can-i-add-new-folder-my-system-path

How to install Git Shell

Windows 7 Ultimate
I used to have Git Shell installed. The icon is grey with a cat face. It was either installed by the Git or by GitHub for Windows.
Somehow I've lost it.
I've tried re-installing both Git and GitHub for Windows, but I can't get it back.
If you have GitHub for Windows (installed, it should come with your shortcut.
It is a shortcut to:
C:\Users\Username\AppData\Local\GitHub\GitHub.appref-ms --open-shell
More recent versions of G4W (see answer below) could have it at:
%LOCALAPPDATA%\Apps\2.0\...\...\
C:\Users\Username\AppData\Local\Apps\2.0\GitHub\GitHub.appref-ms --open-shell
If that shell complains about the absence of git, launch "G4W" itself, which will extract git.
See "Where is git.exe located?".
As mentioned below, to restore the shortcut, after having run the first command, execute in the Git shell:
github --reinstall-shortcuts
Try running the following command:
github --reinstall-shortcuts
That repaired the Git Shell shortcut for me, and also put the proper icon back.
I found out that the answer that you specifically wanted involves a combination of the previous answers:
1. Running the Git Shell via the command line (Since you lost the shortcut)
C:\Users\Username\AppData\Local\GitHub\GitHub.appref-ms --open-shell
2. Once youre in the Git Shell run the command in the previous answer
github --reinstall-shortcuts
You'll find the Git Shell with the grey cat icon that originally came with the GitHub setup in the desktop.
Windows 10
Git-2.19.0-64
The Git Shell is installed by default in:
C:\Program Files\Git\git-bash.exe
Try create a shortcut to your desktop, not sure if this answer your question.
The direct link for Git Shell is now:
https://git-scm.com/downloads
I ran into this same issue today, and since this is the first Google result for my query trying to find a solution, I'll post what I sorted here.
It looks like GitHub for Windows installs some or all of itself into %LOCALAPPDATA%\Apps\2.0\...\...\* and this reference was broken on Git Shell .lnk shortcut on the desktop. The GitHub.exe file pointed to did not exist; the entire path was missing.
I viewed properties on the .lnk file (select Properties from context menu or ALT+ENTER on keyboard with .lnk selected) and clicked the Change Icon button. A message box appeared noting that the path to the old icon file was missing and what the bad path was.
I found the "current" path by poking about in the above noted directory and finding GitHub.exe again. The icon is one of three available in GitHub.exe; I expect this is what some of the other answers (like the reinstall-shortcuts suggestion) accomplish.
Hope this helps someone!
(Which seems to be normal for .NET ClickOnce applications; those ... are randomized/obfuscated/generated so they will look like gibberish. My specific working path, as an example, ended up being: C:\Users\anshou\AppData\Local\Apps\2.0\RZ33EP02.2J7\5OMOZAGM.89T\gith..tion_317444273a93ac29_0001.0003_e68db37a99107794 -- note that this path is not truncated, that is the exact path, double period and all.)

git without bash/cygwin

I'm on a vista laptop, trying out git for the first time.
I installed the msysgit version, and it installed a "git bash" shortcut on the desktop. When I run it, it seems to run in a cygwin kind of box, where C:\ is /c/
Is it safe to use git from the windows command line where /c/ is C:\? does that create any conflict with the way git expects the pathes to be like?
What about, if I init from the bash/cygwin console, then commit from the windows console? Does that create any trouble?
Note: Keep in mind that git does not track where the repository is at -- just references. In other words you can cleanly move an entire git directory (.git + working tree) and it still works fine.
It should work in either case assuming your environment variables allow you to run git from the windows command line.
Both point to the same actual directories (although referenced differently), and use the same executable to modify the repository.
When you install MSYS Git, it will give you 3 options related to system paths. Which one you choose will determine how you can use it. It sounds like you want the 3rd option, "Run Git and included tools from the windows command prompt". This will put all of the git-related binaries in the system path, allowing you to use git from a normal command prompt. Be aware that it also overrides a few built-in windows tools, as the warning in the installer says.
After installing msysgit, you should be able to right click on an empty folder and see options "Git GUI here" and "Git BASH here". If you click Git GUI here it will open a GUI. Have fun!

Resources