Git Bash Beginner's Guide
Tags: tutorial, github, beginners
Published: 2022-09-10 10:42:53

# Introduction
Working on a project that requires an emulation layer for the Git command line interface would require you to know your way around using Git Bash. In this article, I will be breaking down how to install Git Bash, some Git commands you should be familiar with and how to set up a local repository with Git.

**TABLE OF CONTENTS**
1. What Git Bash is and how to utilize it
2. Installing Git Bash
3. Git Commands
4. How to set up your local repository with Git
5. Git Bash paste instructions
6. Conclusion. 



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7b3xtzbna495s3delstw.jpg)
# What is Git Bash ?

 For Microsoft Windows environments, Git Bash is a program that offers an emulation layer for the Git command line interface. The abbreviation BASH stands for Bourne Again Shell. An operating system can be accessed by written commands using a shell and a terminal program. Popular default shells for Linux and macOS are bash. On a Windows operating system, Git Bash is a package that installs Bash together with a few standard bash utilities.

#  Installing Git Bash

## STEP 1
        
Go to the official website to download the Git Bash setup: https://git-scm.com/


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qod5awnrr1vmfayb6fce.png)
The following window will appear once the file has been downloaded

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bfgt7xze1bpyw2t137m.jpg)

## STEP 2

After downloading, run the installer.

## STEP 3
          
Select the components you need to install, launch the.exe file, and follow the installer's instructions.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9w398snwjzxs4vs4ay0.jpg)
## STEP 4
          
 After the installation process has finished, you can launch Git Bash either by using the `cmd` command on your system search or right-clicking in any folder and choosing the **Git Bash Here** option from the context menu. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6xh8bwxfxv8cqe0kgv3v.jpg)
## Git Commands

- pwd

To print the "current working directory," use the Bash command `pwd`. On a DOS (Windows console host) terminal, typing `pwd` is the equivalent of typing cd. The current Bash session is located in this folder or directory.

- ls

To 'list' the contents of the active working directory, use the Bash command `ls`. On a Windows console host terminal, `ls` is the equivalent of DIR. 
`ls` to list the contents of the current directory.

- cd

The `cd` command in both Bash and Windows console host. Change Directory is referred to as `cd`. An added directory name is used when using `cd`. `cd` changes the working directory of the terminal session to the directory specified by the passed directory argument.

- git config --global user.name

    This comment will set your name.

- git config --global user.email

     This comment will set your email.

- git init 

     Create a new blank repository and initialize an existing directory as a git repository.

- git commit

    Changes are saved to the local repository.

- git status 

    Displays the status of the working directory and the staging area.

- git remote

     Manage the set of remotes that you are tracking with your local repository.

- git checkout 

     Match your working directory with your last commit. 

- git log

     Shows the commit history for your current active branch.

- git pull 

     Fetches and merges on the remote server to your working directory.

- git push

     Changes the master branch to your remote repository.

- git merge 

     Merges the specific branches history into the current branch.

- git rm

     Remove your file from your working directory and git staging area.

- git diff

     Shows changes between commits.

- git touch

     Creates a blank file inside your folder.

- git add -a

     Add all modified and deleted files only to the staging area.

- git checkout -f

     Match all your working directory file with your last commit.

- git log -p

     See any particular "one" or more than one commit.

- git diff --staged

     Compares the staging area to the last commit.

- git rm --cached

     Removes your file from the staging area.

- git branch -b

     Creates a new branch and opens that particular branch.

##  To Set Up Your Local Repository With Git

follow the steps below:

###  STEP 1

Make a GitHub repository.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ffhmbqbt93ma5zo4etv4.jpg)

### STEP 2
 
 Give your repository a good name and create the repository.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jeqs9y71ajec4lrbh5uk.jpg)

Note: You can choose to include information about your project in the README file that comes at the top of your git repository. It helps give vital information about your project. However, it is not strictly required. If you start your repository with a README file using the GitHub interface, your local repository won't have this README file. To prevent encountering an issue while attempting to push your files (as in step 3 of the following section), carry out the following steps to pull that file to your local folder after step 5 (where you setup your local folder as your git repository):

​### STEP 3

 The following will show up following repository creation.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m482evcbtu462dmpwqs6.jpg)
​
### STEP 4
  
Open Git Bash and use the cd command followed by the name of the project to move to the local project.
​

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hxzg2mdh5f3plogz8o6d.jpg)
### STEP 5
  
 Create a Git repository in the local directory.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rjf30cejyp5s44rb93x.jpg)

### STEP 6 
       
 Before the initial commit, stage the files by adding them to the local repository using (`git add .`)

### STEP 7
    
The staged files can be seen with "git status"


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkrpih3ds1w4pscy1413.jpg)
### STEP 8
 
The files you've staged in your local repository should now be committed using ( git commit -m "commit message" )


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xts7i8v0xla2kq75nnfo.jpg)
​Since there is nothing remaining to commit after running the "git status" command, all files have already been committed.

## Git Bash paste instructions.

**Linux**

Type Ctrl+Shift+V

**Windows**

Consider one of the following options:

1. Press the Insert+Shift button.

2. Using the mouse, do the following: Right Click -> Edit -> Paste

3. Enable the "Quick Edit" mode and use the Ctrl+V shortcut as usual:

Right-click and choose "Properties."
Choose the "Options" tab.
Check the box next to "Quick Edit Mode."
If a "Experimental" tab appears, select it and then check the top "Enable experimental console" and "Enable new Ctrl key shortcuts" options.
To save, click 'OK.'
You can now paste using Ctrl+V.

# Conclusion

We were successful in covering Git Bash at a beginner's level and how to use it. When using Git Bash, the commands will be useful.

This has been a long read, if you made it this far then I genuinely hope you find the information useful.
I appreciate your time.






​
       
        

###