96

Git Bash

I have been working with Git Bash for the last two days. I know now the basic operations such as commit, push, pull, fetch, and merge. But I still don't know what Git Bash itself actually is!

I've searched a lot about Git Bash, but all sites which I have seen focus on the functionality of its commands. I still haven't found a good answer for my question. Now, I think, I'm in the right place to get this answer!

DRAJI
  • 1,771
  • 6
  • 23
  • 44
  • 4
    People may also be interested in my question on SuperUser [What is Git Bash for Windows anyway?](https://superuser.com/questions/1053633/what-is-git-bash-for-windows-anyway) – geneorama Sep 12 '18 at 18:21
  • There's no such thing as "Git bash". There is "bash" and there is "git". Bash is an interactive command line interpreter, sometimes also called just "sh" or "shell" for historical reasons, analoguous to Microsoft's "cmd". There *is*, however, "git shell", which is a "locked-down" command interpreter used to limit the power of anonymous access to git servers, and is part of the git distribution. Since git was developed *on* and *for* UNIX like systems, it is best paired with "bash" CLI, although, in theory, it is shell-agnostic. – Hatebit Sep 29 '19 at 16:58

4 Answers4

80

git bash is a shell where:

See "Fix msysGit Portable $HOME location":

On a Windows 64:

C:\Windows\SysWOW64\cmd.exe /c ""C:\Prog\Git\1.7.1\bin\sh.exe" --login -i"

This differs from git-cmd.bat, which provides git commands in a plain DOS command prompt.

A tool like GitHub for Windows (G4W) provides different shell for git (including a PowerShell one)


Update April 2015:

Note: the git bash in msysgit/Git for windows 1.9.5 is an old one:

GNU bash, version 3.1.20(4)-release (i686-pc-msys)
Copyright (C) 2005 Free Software Foundation, Inc.

But with the phasing out of msysgit (Q4 2015) and the new Git For Windows (Q2 2015), you now have Git for Windows 2.3.5.
It has a much more recent bash, based on the 64bits msys2 project, an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. msys2 comes with its own installer too.

The git bash is now (with the new Git For Windows):

GNU bash, version 4.3.33(3)-release (x86_64-pc-msys)
Copyright (C) 2013 Free Software Foundation, Inc.

Original answer (June 2013) More precisely, from msygit wiki:

Historically, Git on Windows was only officially supported using Cygwin.
To help make a native Windows version, this project was started, based on the mingw fork.

To make the milky 'soup' of project names more clear, we say like this:

  • msysGit - is the name of this project, a build environment for Git for Windows, which releases the official binaries
  • MinGW - is a minimalist development environment for native Microsoft Windows applications.
    It is really a very thin compile-time layer over the Microsoft Runtime; MinGW programs are therefore real Windows programs, with no concept of Unix-style paths or POSIX niceties such as a fork() call
  • MSYS - is a Bourne Shell command line interpreter system, is used by MinGW (and others), was forked in the past from Cygwin
  • Cygwin - a Linux like environment, which was used in the past to build Git for Windows, nowadays has no relation to msysGit

So, your two lines description about "git bash" are:

"Git bash" is a msys shell included in "Git for Windows", and is a slimmed-down version of Cygwin (an old version at that), whose only purpose is to provide enough of a POSIX layer to run a bash.


Reminder:

msysGit is the development environment to compile Git for Windows. It is complete, in the sense that you just need to install msysGit, and then you can build Git. Without installing any 3rd-party software.

msysGit is not Git for Windows; that is an installer which installs Git -- and only Git.

See more in "Difference between msysgit and Cygwin + git?".

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 2
    i want to know just meaning about that! – DRAJI Jul 24 '13 at 05:10
  • @DRAJI do you mean my answer didn't cover what you wanted to know? – VonC Jul 24 '13 at 05:26
  • @DRAJI is there any more detail you would want to know about "`git bash`"? – VonC Jul 24 '13 at 05:41
  • Of course. But First of all i want to know just two line description about that.After that i will take a next step. – DRAJI Jul 24 '13 at 05:45
  • @DRAJI I have added context and the "two lines description" (the ones in bold, starting with "Git bash is a msys shell included in...") – VonC Jul 24 '13 at 05:56
  • Thank you so much @VonC for spent me your valuable time. Now i have cleared about this concept. Thanks once again! – DRAJI Jul 24 '13 at 07:46
  • 3
    for instance, what is the difference between UNIX Bash and Git Bash? – Alexander Mills Sep 05 '14 at 07:45
  • I want to ask whether git bash is a good choice to use bash (linux shell) in Windows OS which can reach the whole directory. I want to reach the whole directory from "C:/". And cygwin looks very heavy while git bash is very light. – Joonho Park Dec 18 '19 at 03:31
  • @JoonhoPark `ls /c` (lowercase c) does work in my git bash session – VonC Dec 18 '19 at 04:58
23

I think the question asker is (was) thinking that git bash is a command like git init or git checkout. Git bash is not a command, it is an interface. I will also assume the asker is not a linux user because bash is very popular the unix/linux world. The name "bash" is an acronym for "Bourne Again SHell". Bash is a text-only command interface that has features which allow automated scripts to be run. A good analogy would be to compare bash to the new PowerShell interface in Windows7/8. A poor analogy (but one likely to be more readily understood by more people) is the combination of the command prompt and .BAT (batch) command files from the days of DOS and early versions of Windows.

REFERENCES:

O.M.Y.
  • 347
  • 2
  • 14
10

Bash is a Command Line Interface that was created over twenty-seven years ago by Brian Fox as a free software replacement for the Bourne Shell. A shell is a specific kind of Command Line Interface. Bash is "open source" which means that anyone can read the code and suggest changes. Since its beginning, it has been supported by a large community of engineers who have worked to make it an incredible tool. Bash is the default shell for Linux and Mac. For these reasons, Bash is the most used and widely distributed shell.

Windows has a different Command Line Interface, called Command Prompt. While this has many of the same features as Bash, Bash is much more popular. Because of the strength of the open source community and the tools they provide, mastering Bash is a better investment than mastering Command Prompt.

To use Bash on a Windows computer, we need to download and install a program called Git Bash. Git Bash (Is the Bash for windows) allows us to easily access Bash as well as another tool called Git, inside the Windows environment.

Suraj Kumar
  • 5,290
  • 8
  • 18
  • 37
  • 1
    As an aside, the current CLI for Windows is PowerShell. The ancient DOS-based CMD shell is still around for compatibility but MSFT focuses all their attention on PS. It's pretty nice, really, taking the pipe-oriented features of Unix-based shells (bash, sh, csh, ksh, zsh, etc.) and extending them to allow passing objects, vs just text. – Peter Halverson Feb 22 '19 at 19:12
3

At its core, Git is a set of command line utility programs that are designed to execute on a Unix style command-line environment. Modern operating systems like Linux and macOS both include built-in Unix command line terminals. This makes Linux and macOS complementary operating systems when working with Git. Microsoft Windows instead uses Windows command prompt, a non-Unix terminal environment.

What is Git Bash?

Git Bash is an application for Microsoft Windows environments which provides an emulation layer for a Git command line experience. Bash is an acronym for Bourne Again Shell. A shell is a terminal application used to interface with an operating system through written commands. Bash is a popular default shell on Linux and macOS. Git Bash is a package that installs Bash, some common bash utilities, and Git on a Windows operating system.

source : https://www.atlassian.com/git/tutorials/git-bash

  • 2
    "Git is a set of command line utility programs that are designed to execute on a Unix style command-line environment"... true, and not surprising, considering Git was created by Linus Torvalds (https://en.wikipedia.org/wiki/Linus_Torvalds) – VonC May 02 '19 at 13:01