Git has been widely used among software engineers. It is not only free, but is also open-source. In addition, it’s powerful for its distributed nature, fast operation and branch handling mechanism. The distributed property makes it easy and efficient for multiple developers to work together. And this is very useful for group project. Meanwhile,
Git works fast with its lightweight operations. Lastly, every developer can work with the code as its own branch. Others can merge different branches. Thus, this makes cooperation-work quite easy.
In the meanwhile,
Bash is a very popular shell. It stands for
Bourne Again Shell. A shell is a user interface to access to an operating system’s services. And it’s also called command-line interpreter. Basically,
shell could be a connection between engineers and operating system. Specifically, we can use commands to access or modify files in operating systems.
In this article, I’ll introduce how to combine these two together. More specifically, I’ll focus on how to set both up and make them work. Furthermore, we know that in Unix-like OS and MacOS,
Bash is the default shell. So in this article, I’ll emphasize on Windows system.
Below, all the operations are in Windows 10 and
Git 2.9.2 version.
2. Git Bash installations and settings
First of all, we know that it’s relatively hard to use command in Windows system. This could be painful for software developers. In Windows, there’s a cmd window, which is similar to the terminal in Unix-like system. However, as I mentioned, it does not support commands. For example, the list ls command like below:
However, things could change. We can use the
Git bash, which supports both the
Git and the bash shell.
2.1 Git Bash installation
Primarily, we need to download the
Git. Go to the link of https://git-for-windows.github.io/. Then download it, as shown below:
After downloading, you need to install it.
During the installation, make sure that you check one option – the
Git Bash like below:
After successful installation, you can check out the software and find the
Git Bash like below:
Then click the
Git Bash, and start a bash shell integrated with
Git. This could be really awesome to start working on. Here, you might want to check out whether it’s done with command
$ git --version git version 2.9.2.windows.1
2.2 Git Bash setting
Next, you need to set up the
Git Bash with your
Github account. Make sure you have registered one for yourself.
After registration, open the
Git Bash window. This is used for setting up the global parameters. In addition, this will connect your local repository with remote repository –
Bash, type following command:
$ git config --global user.name "username"
In the quote, replace the username with your real
Github user name.
Then, input another command:
$ git config --global user.email "useremail"
Similarly, replace the user email with your real
Github email. That’s it, all settings are done!
3. Git Bash usage
3.1 Git Bash in Windows
After the previous installation and settings, you can start working on the real
Git project. For example, right now you are able to use the command like in Unix-like system.
In addition, you can use other popular commands, like cd, mkdir, rm etc. All these commands are supported in
Git Bash now. For further commands, you may refer to the link: http://ss64.com/bash/
Git Bash also supports
Git operation. For example, you might want to use
git clone to clone a project from
Here, notice that in the command, it’s better to type the whole command, instead of copying. I encountered an error when I was copying the link directly to the bash. It’s like below:
In addition, you can try more
Git operations like below:
Git operations, you may refer to one of my previous article. The link is Git tutorial for beginners.
3.1 Git Bash in Mac/Unix
As I mentioned before, bash is the default shell for both MacOS and Unix-like system. You can check this by typing the following command:
WXMs-MacBook-Pro:~ WXM$ echo $SHELL /bin/bash
Also, you can check all the shells that your OS supports.
WXMs-MacBook-Pro:~ WXM$ cd /bin/ WXMs-MacBook-Pro:bin WXM$ ls [ df launchctl pwd tcsh bash domainname link rcp test cat echo ln rm unlink chmod ed ls rmdir wait4path cp expr mkdir sh zsh csh hostname mv sleep date kill pax stty dd ksh ps sync
And, you can find other shells, like csh, sh, zsh, tcsh etc.
Git Bash is very useful for developers to work in Windows environment. This article explained the basic installation and settings for
Git Bash. Furthermode, it is also explained
Github configuration. Happy