Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Windows what is the difference between Git Bash vs Windows Power Shell vs Command prompt

I am a Mac guy who is used to Mac's Terminal. Now I am using Windows.

  • Whats the diff between those CLI options?
  • When should I use one over the other?
  • Are there more CLI options that I should consider?
  • What CLI would you use if you were a Mac person trying to adapt to Windows?

The reason I am trying to use Windows, is that I want to ensure the CLI of my Docker projects work for Windows users, that I can write files coming from my container to Windows and ensure my README files have instructions for Windows users. And basically test everything I do on Windows too, like Python.

like image 882
heart.cooks.mind Avatar asked May 29 '19 13:05

heart.cooks.mind


People also ask

Is Git Bash same as command prompt?

As you can tell, all Git commands work in both Git Bash and the command prompt. And since Git is delivered as a Unix-style command-line environment, let's try running a Linux command on the Git Bash console!

What are the differences between PowerShell command prompt and bash?

1. PowerShell is a command shell and associated scripting language for the majority of windows operating system. 2. Bash is the command shell and scripting language for the majority of the Linux operating system.

Should I use bash or PowerShell on Windows?

Administrators can manage Windows server workloads or host production Linux workloads and server applications via PowerShell. Bash, on the other hand, is more traditionally suited for development environments. It was introduced to complement and strengthen CLI-based interaction.

What is the difference between GIT CMD and Git Bash?

Git CMD is like a regular windows command prompt with the GIT command. It allows you to use all git functions from the command line. This is useful if you are already familiar with windows CMD and you only work on windows. Git bash simulates the bash environment on windows.

What is the difference between SSH and power Shell in Git?

Git bash allows use of ssh protocol to interact with git repositories from a Windows command line but not the default one. Power shell is another cmd line and scripting language for windows with a differing syntax from cmd. Only Windows applications can be launched from Powershell.

What is the difference between poshgit and Git Bash?

PoshGit will let you use Windows and Power Shell commands with Git at the command line, while Git Bash will let you use MinGW/Linux tools with Git at the command line. Well, for one thing, the default shell that comes with GitHub for Windows is PoshGit, which is a Windows Power Shell environment for Git.

What is the difference between PowerShell and CMD in Linux?

CMD is the command line for Microsoft Windows operating system, with command-based features. Powershell is a task-based command-line interface, specifically designed for system adminsand is based on the .Net Framework. Bash is a command-line and scripting language for most Unix/Linux-based operating systems.


1 Answers

Git bash is bash, which is IIRC also the default shell on MacOS. It is not the default shell on Windows, although several implementations exist (CygWin, MinGW, ...).
Git is bundled with a number of POSIX (UNIX/Linux/etc.) utilities in addition to bash; in order to avoid "collisions" with similarly named Windows commands, the most common installation option is to install bash in such a way that the other POSIX commands are only available when running bash. The Git installer will create a shortcut to launch this "private" version of bash, hence "git bash".

The Windows command prompt runs the default Windows shell, CMD.EXE, which is a derivative of the old MS-DOS command shell, COMMAND.COM. It is much less capable than most POSIX shells; for example, it did not until relatively recently support an if/then/else construct, and it does not support shell functions or aliases (although there are some workarounds for these limitations).

PowerShell is more of a scripting environment. I'd compare it to Perl on UNIX/Linux systems -- much more powerful than the standard shell, but not necessarily something I'd want to use at the command line.
One thing to be aware of is that some of the nicer PowerShell features may require you to update your version of PowerShell -- the version bundled with Windows is typically a few years old. And updating PowerShell usually requires admin privilege; depending on the version, you may also need to update the .NET framework.


If I were a Mac person trying to adapt to Windows ... it depends. In the short term it would be easier to use something familiar like bash. But long term, you -- and more importantly, your potential users -- may not want to be dependent on a third party tool, especially since for Windows users that will typically present an additional learning curve.

As to which to use when ... it really depends on what you're trying to accomplish -- both in terms of technical functionality and the interface you want to present to your users. As noted above, I'd consider PowerShell more appropriate for scripting than the CLI, unless you just need to run a cmdlet (either a built-in or one you've created yourself).

like image 128
David Avatar answered Sep 27 '22 23:09

David