Hi everyone, first-time Git user here! Just wanted to ask if there's a simple way to run Git commands directly from PowerShell without launching a separate CMD window or the Bash terminal.
I've installed Git, and I can see the executables at:
C:\Program Files\Git\git-bash.exe
C:\Program Files\Git\git-cmd.exe
For now, I manage to clone repos by running git-cmd via File Explorer's context menu or a temporary CMD window:
cd "c:\temp"
git clone https://github.com/SomeName/SomeRepo
But I'd love to do this entirely within my PowerShell environment in Windows Terminal. When I try to source the Git executable directly, it behaves oddly:
. "C:\Program Files\Git\git-cmd.exe" clone "https://github.com/SomeName/SomeRepo"
This opens a CMD window, executes the command, closes immediately, and then my PowerShell prompt switches to a CMD-style interface. I'm hoping to stay inside PowerShell and just run a single git clone command without context switching.
I also tried sourcing git-bash.exe, but that just launches its own full terminal window:
. "C:\Program Files\Git\git-bash.exe" clone https://github.com/SomeName/SomeRepo
And I tried using the /c flag with git-cmd:
. "C:\Program Files\Git\git-cmd.exe" /c clone "https://github.com/SomeName/SomeRepo"
That didn't work either. I'm sure I'm missing something obvious, but I wouldn't expect to be digging into this too late at night! Any help would be greatly appreciated.
Source: Super User Archive (CC BY-SA 4.0)