September 10th, 2024

Git Bash Is My Preferred Windows Shell

Git Bash is a Windows command-line shell that emulates Unix-like bash, allowing Unix commands and Windows variable access. It offers easy installation, customization, and community support for users.

Read original articleLink Icon
Git Bash Is My Preferred Windows Shell

Git Bash is a command-line shell for Windows that emulates the Unix-like bash shell, making it a preferred choice for users familiar with bash commands. It is packaged with Git for Windows and offers a range of features that enhance usability, such as the ability to pipe command outputs, access to Unix commands, and compatibility with Windows environment variables. Users appreciate its ease of installation, small footprint, and the convenience of launching it directly from Windows File Explorer. Git Bash supports scripting and allows users to create and edit bash profiles for customization. It also features Mintty as its default terminal emulator, which can be customized for color schemes and fonts. The article highlights the importance of community resources for learning and troubleshooting Git Bash, as well as tips for managing installations, updates, and customizations. Overall, Git Bash is favored for its functionality and user-friendly interface, especially for those who have a long history with Unix-like systems.

- Git Bash is a command-line shell for Windows that emulates the Unix bash shell.

- It allows users to run Unix commands and access Windows environment variables.

- The shell is easy to install and integrates well with Windows File Explorer.

- Customization options are available for the terminal emulator Mintty.

- Community resources are valuable for support and learning about Git Bash.

Link Icon 32 comments
By @locusofself - 5 months
I started using Linux in 1997. I've been working at Microsoft for a little over 4 years. There are some annoying things about Powershell (verbosity and slow loading of tab completions etc), but in some ways it's vastly superior to bash, as it deals with structured data and not just strings you have to parse, and it has an extremely powerful standard library API (.NET) at your fingertips.

I still love bash and use it as well. But the hate powershell often gets is misguided.

By @delta_p_delta_x - 5 months
> I like Git Bash because…

> I’m more comfortable with bash commands than CMD or PowerShell commands (because I’ve been using Bourne shell (sh) and friends for more than 30 years).

This is the only argument I'm willing to accept, and honestly it's the only argument the writer needs, really: un-learning 30 years of experience to use something else even if the latter is objectively superior, would be a pain in the neck for anyone.

That being said I believe that seriously attempting to use the native tools would help the author understand Windows at a more fundamental level.

Also, this does raise a few questions, though—if the writer has been using UNIX shells for that long, why are they using Windows at all? As I commented elsewhere, why shoehorn the whole set of UNIX core utilities and binary utilities onto Windows when the latter comes with its own shell, command-line utilities, and management tools? More importantly, the author going by the rest of their posts (assuming it was the same author) doesn't strike me as the type (i.e. normie, for lack of a better word) to use Windows as a daily driver, but they seem to use it all the same. Therefore, why not an OS where these utilities feel more native and more useful, like Linux or one of the BSDs?

In contrast to the author I've been using and programming almost nothing but Windows (with a brief stint on Linux in university and now at work, but only for work), and on Windows I use PowerShell and if I really need to, CMD.exe (good riddance). As far as compilation goes, I use Visual Studio with MSVC and Clang-Cl, because they are the only complete development environment for Windows—all the others (MinGW, Cygwin, MSYS2) are incomplete or worse in some way, or make life harder than necessary in some way.

> I have experience using Windows PowerShell (powershell.exe), but do not yet have experience using the cross- platform PowerShell Core (pwsh).

For the record, functionality between powershell.exe and pwsh.exe is almost identical, with some minor differences[1]. Additionally they differ in the .NET runtime they were written against (.NET Framework 4.8 for powershell.exe, and .NET 7 and later for pwsh.exe).

[1]: https://learn.microsoft.com/en-gb/powershell/scripting/whats...

By @sevensor - 5 months
Its biggest advantage is how easy it is to convince corporate IT that you need Git for Windows, compared to msys2, Cygwin, or WSL.
By @doctorpangloss - 5 months
Busybox for Windows is much better.

- Paths look much better: C:/Users/doctorpangloss == /Users/doctorpangloss == C:\Users\doctorpangloss.

- The coreutils are just there.

- Works flawlessly as an SSH or Dockerfile shell.

- Fast and tiny. So small you can check it into git.

- The maintainer is very responsive and fixes bugs quickly, even in upstream.

git-bash has problems because of paths, terminal weirdness, and it doesn’t use native Windows APIs for a variety of things where it should. /c/ this, /mnt/ that. It’s not really possible to write multi platform scripts with it. With Busybox for Windows you can.

By @JackMorgan - 5 months
As a long time personal and professional Linux user, lately my work has led me to work for companies that are Windows-only. I use git bash as my main shell on Windows. It just works for what I need, and in the rare cases I need powershell I just open that.

Most of the windows-based programmers I interact with don't know powershell any better than I do. They use GUI tools for interacting with git and the filesystem.

So for me, git bash for git and filesystem interaction is a superpower in these places.

I could learn powershell, and I'm pretty sure it's much better than bash for scripting, but I'm almost never really scripting in bash anyway, I use tools like F# for that. Powershell seems fine, but it's less well supported on Linux and I don't really need a shell based language.

So in the end, git bash keeps on working and I can focus my learning elsewhere. It's stable, still works the same way 15+ years later, so no need to change.

By @niobe - 5 months
Well I took a different route.

Always beem 'forced' to use Windows as my workstation by a couple of specialty apps without Linux alternatives that need direct hardware access. But have always used linux on everything else (servers, even my media centre). Because I'm sometimes a late adopter of new tech, until recently I used cygwin as my normal command prompt. There were few downsides to that if you just need access to unix tools, except package management is a bit annoying. Well, discovered the MS Terminal and WSL this year, and happily moved off cygwin. More recently decided to switch over from WS1 to WSL2 but still evaluating the move.

Now I have a unix "more native" environment AND a linux distro I'm familiar with. I've been accessing the Windows filesystem under /mnt for two decades so this is normal for me, and if filesystem access is slower, it's not a dealbreaker. All my existing scripts were trivial to update. The integration of WSL and VSCode is also pretty cool. It means my vs code environment environment is also working natively in my WSL distro.

Overall can understand some lingering negativity about MS efforts in this dept but after years of rejecting all things linux and open source, in general the 180 from the top is much appreciated and it has kept me on Windows a while longer...so mission accomplished microsoft. Just gotta do something about those pesky apps I still need...

By @dundarious - 5 months
git bash's main benefit being that it's a commonly installed variant of the wonderful msys2 system, then yes, I tend to agree.

Another wonderful benefit of git bash, is that because it is so commonly installed, if you want scripting for a dev/build tool, you can 99% of the time just use bash for your scripts, on linux and windows.

I use this all the time for my build scripts. build/x86_64-linux-gnu-gcc.sh, build/x86_64-windows-msvc-cl.sh, etc. (These are generally simple single command line unity builds, parameterized only by debug, opt, etc.)

Then from pwsh I can run these scripts with `& "$env:GIT_INSTALL_ROOT\bin\bash.exe" .\build\x86_64-windows-msvc-cl.sh`, similarly from cmd.exe. (Looks like a ton of typing, but it's not, I always Ctrl-R search and get a hit by just typing "git_").

No need to write a bat script, or even a pwsh one, pretty much ever again. Even if all you want is logic to cd to the script directory, parse a single script argument, check it's valid, provide a default, make some directories if not present, etc., bash beats all the alternatives on many fronts.

By @ruthmarx - 5 months
I've been pretty happy with clink [0].

I'm not looking to have the same environment everywhere, I'm fine to have windows stuff optimized for windows on windows, and vice versa on Linux.

By that reasoning, I think clink is a much better option.

[0] https://github.com/chrisant996/clink

By @kennethrc - 5 months
I'm "All Linux, all the time" at home, develop in it, help out with the Kernel a little bit, only use Windows at home in a VM, etc.

I'd just started working for a client that is fully entrenched in Windows, but we're doing bare-metal and Linux-y work. When I'd discovered I couldn't use Linux as my daily driver due to security/policy(/tooling) reasons, one of my co-workers told me about Git Bash, and it's worked out so well that ... <looks left, looks right> ... when we were given the opportunity to use Linux but VM Windows, I kept the Windows machine.

GitBash has made Windows painless for my work's use-case. I should probably throw a few $$ at them ....

By @pauliusj - 5 months
Coming from mac to windows, a big surprise was how ridiculously slow printf is on any of the ms terminals (cmd, powershell, windows terminal). Git bash does not have this problem when you are running something pretty verbose yet want to view the output in the terminal
By @mid-kid - 5 months
My favourite shell environment for windows thus far is combining Git For Windows with scoop[1]. A simple "scoop install git" will get the environment installed, and give you a bash shell and full access to all sorts of windows-native utilities from scoop. Some would say I'd be better off with msys2 or cygwin, but the former is meant more as a development environment and lacks misc utilities, and the latter has what is possibly the worst package manager that is still in use (and generally less stellar integration with windows programs).

[1]: https://scoop.sh/

By @bena - 5 months
It's weird, I mostly associate git bash with VS Code because it's the terminal I use most often with it.

It doesn't occur to me to use it outside of that context. I use the command shell or Powershell depending on what I need to do.

By @NelsonMinar - 5 months
git bash is very cool. It's based on good ol' MSYS2 and MinGW which has always been a nice way to do minimalist Unix-like stuff in Windows.

WSL2 is great these days and can interact fine with Windows files (despite what this article says). But it's a lot more stuff, a full Linux install in a VM.

By @WalterBright - 5 months
I constantly switch back and forth between Windows and Linux and it's always "dir" mixed up with "ls" coming from my fingertips. Grump grump grump

Edit: I know I can use aliases and .bat files and whatever to make one look like the other, sort of, but then I learn some patchwork system and will be unable to use any other computer's login.

By @Hackbraten - 5 months
For me, the biggest downsides to Git Bash are:

1. I don’t understand how it relates to msys2 and where the boundary is, so I’m always reluctant to apply msys2 practices (documentation, advice, blog posts, etc.) to Git Bash.

2. I’ve been unable to figure out how to package scripts and other software for Git Bash so other users can install them.

By @4oo4 - 5 months
Git Bash is really nice for when I want a unix utility that will do the job simpler and better than Powershell, however it's painfully slow for larger I/O operations.

I end up barely using it on my Windows 11 work machine because I'm allowed to have Linux VMs. Even with the VM overhead, and having fewer CPU cores and less RAM than the host, things still end up being way faster there.

I remember one time running a grep command on a large-ish (~ 1 GB) log file in Git Bash and waiting at least 5 minutes for it to complete. After getting impatient I did the same thing in a VM and it took about 30-45 seconds, at which point Git Bash still had not finished.

By @AdeptusAquinas - 5 months
Huh, didn't know it was basically bash commands for windows - I thought it was a faked up linux environment.

I mostly just use ubuntu under wsl2, though the file performance across the windows filesystem isn't the best.

By @konfekt - 5 months
For those without admin rights preferring ZSH to Bash in the Windows Terminal: install MSYS2 with scoop.sh, then the ZSH package with `pacman -S zsh` and add a shell with commandline `%USERPROFILE%\\scoop\\apps\\msys2\\current\\msys2_shell.cmd -defterm -here -no-start -ucrt64 -shell zsh` to launch it in Windows Terminal.
By @yamapikarya - 5 months
i love windows terminal + git bash combo
By @daghamm - 5 months
WSL inside the new Microsoft Terminal is my preferred Windows Shell.
By @amatecha - 5 months
Oh yeah, I've been using Git Bash for years, it's great. It's nice being able to use a set of basic cli utils I'm used to (gnu utils) which are bundled in (not sure if it's 100% exhaustive in that regard, but still enough for me to do everything familiar). And yes, agree with and have benefited from every single bullet point TFA mentions!
By @rr808 - 5 months
The reason I used to use Git Bash was to ssh to Unix boxes. Since Windows Terminal came out I dont use any more, Windows Terminal is much better.
By @johnea - 5 months
Why not just ditch the "windows" part entirely, and work on an OS that's not designed for the purpose of exploiting you as a user?
By @esalman - 5 months
Git SDK for Windows is even more awesome, complete with a package manager for fetching more common unix tools with ease.
By @dietr1ch - 5 months
Same, but NixOS is my preferred Windows too.
By @lynguist - 5 months
In this article I learned that _start_ is the equivalent of _open_ (from Mac). I didn’t know _start_ before.
By @aurelien - 5 months
You should try ArchLinux or Gentoo if you really want a shell as you desire ;)
By @nikau - 5 months
Gitbash is handy for simple things, but it's a slug compared to wsl2.
By @cafard - 5 months
I was just using Git Bash to run grep...
By @bricss - 5 months
Git Bash + Windows Terminal = one luv
By @veltas - 5 months
mintty is a great TTY emulator for Windows
By @righthand - 5 months
Honestly there are so many differences and little things on Windows that make using any of the CLIs not worth it. You will run up against gotchas developing on native Windows cmd, Powershell, git bash, and WSL. I left for Linux a long time ago and never have had to look back at the utter mess that is Windows. People stay on that platform for what? A graphical menu in the corner? Compatibility you don’t actually need? Use a real shell and OS and save your sanity.