Home > front end >  How to install git (with bash on power shell) on power shell?
How to install git (with bash on power shell) on power shell?

Time:08-11

https://gitforwindows.org/ has an option to put bash into power shell. I need that so no installing WSL and etc. I need to install git unnatended, that is, with command line only. Existing tutorials like this https://www.delftstack.com/howto/powershell/powershell-install-git/ only launch the installer using power shell, but I have to use the mouse to install stuff.

So, how to install git, with bash on powershell, using powershell?

UPDATE:

I tried

Write-Host "Installing Git for windows..." -ForegroundColor Cyan
$exePath = "$env:TEMP\git.msi"

Write-Host "Downloading..."
(New-Object Net.WebClient).DownloadFile('https://github.com/git-for-windows/git/releases/download/v2.37.1.windows.1/Git-2.37.1-64-bit.exe', $exePath)

Write-Host "Installing..."
Start-Process msiexec.exe -Wait -ArgumentList '$exePath /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS="icons,ext\reg\shellhere,assoc,assoc_sh" /LOG="C:git-for-windows.log"'

git --version
bash

but it gets stuck on "Installing..." and does not print any other outputs.

CodePudding user response:

This is not the exact answer for your question.

Since you do not prefer something as heavy as WSL, I have a good alternative for your purpose that also promises native windows filesystem support. Use MSYS2 instead of gitbash. This is far better and git-bash is originally based on MSYS2

  1. Download the prefered package of MSYS2.
  2. If you downloaded the GUI installer, install it via CLI with .\msys2-x86_64-latest.exe in --confirm-command --accept-messages --root C:/msys64

Or if you had downloaded the self extracting archive, install it using .\msys2-base-x86_64-latest.sfx.exe -y -oC:\

  1. Lauch MSYS2, then update the packages list with pacman -Syu.

  2. Install git with pacman -S git

You will eventually come to love it. Note that some keyboard shortcuts you are used to in linux may not work example Ctrl Shift v for pasting is not supported and Windows uses Shift Insert

Credits

CodePudding user response:

Just in case, check if the /LOG="C:git-for-windows.log" part of your command has a typo

 /LOG="C:\git-for-windows.log"
        ^^^ 
        (\ was missing)

That way, you can try again, and monitor C:\git-for-windows.log for logs.

Also, make sure you have the right to write directly under C:\.
A /LOG="$env:userprofile\git-for-windows.log" might be safer.

  • Related