Git Bash (original) (raw)

Last Updated : 11 May, 2026

Git Bash is a Unix-like command-line interface for Microsoft Windows that lets developers run Git commands and manage repositories from a terminal, bringing Linux-style workflows to Windows.

Usage of Git Bash

Git Bash is used to run Git commands and Unix-style CLI tools on Windows to manage repositories and automate development tasks.

Git GUI

Git GUI tools provide a visual interface to perform common version control tasks, making Git easier to use than the command line for many users.

Steps to Install Git Bash

Step 1: Download and Run The installer

The .exe file installer for Git Bash can be downloaded from "https://gitforwindows.org/" Once downloaded execute that installer, following window will occur.

GitInstall

Git Bash Installation

Step 2: Select required options

Select the components that you need to install and click on the Next button.

git components to be installed

Install Git Bash

Step 3: Select Installation Directory

Select the path where you want to install git as shown in the image below.

Adjusting the path

Install Git Bash

Step 4: Wait for Completion

Let the installation process finish to begin using Git Bash. To open Git Bash navigate to the folder where you have installed the git otherwise just simply search in your OS for git bash.

Installing Git

Install Git Bash

Git Opened

Install Git Bash

Basic Git Bash Commands

Here are some fundamental Git Bash commands to get you started:

**Navigating Directories:

**Managing Files and Directories:

**Using Git Commands:

**Working with Git Bash on Windows

Git Bash allows you to interact with the Git version control system in a command-line environment on Windows.

Step 1: Configuring Git

**Set your global username/email configuration:

Open Git Bash and begin creating a username and email for working on Git Bash.

**Set your username:

git config --global user.name "FIRST_NAME LAST_NAME"

**Set your email address:

git config --global user.email "MY_NAME@example.com"

cd command refers to the command line change directory and is used to get into the desired directory. To navigate between the folders the cd command is used

cd folder_name

ls command is used to list all the files and folders in the current directory.

ls

Open Git Bash and change the current working directory to your local project by use of the cd command.

Change Working Directory

Step 2: Commit Repository in Git Bash

Initialize the local directory as a Git repository.

git init

Stage the files for the first commit by adding them to the local repository

git add .

By "git status" you can see the staged files after that Commit the files that you've staged in your local repository.

git commit -m "First commit"

Now After the "git status" command, it can be seen that nothing to commit is left, Hence all files have been committed.

Step 3: Initializing a Local Git Repository

Follow the steps given below to initialize your Local Repository with Git. Open GitHub through the internet and click on create new repository Give a suitable name for your repository and create the repository.

Creating New Repository

Initiailzed Git Repo

**Note: Initializing your GitHub repo with a README is optional, but if you do, the README won’t exist in your local repo unless you pull it first.

The following will appear after creating the repository

New Repository

Step 4: Connect the local Repository to GitHub

Go to the GitHub repository and in the code, section copy the URL and In the Command prompt, add the URL for your repository where your local repository will be pushed.

git remote add origin repository_URL

Push the changes in your local repository to GitHub.

git push origin master

Here the files have been pushed to the master branch of your repository. Now in the GitHub repository, the pushed files can be seen.

Step 5: Pulling and Pushing Changes to GitBash

Suppose the files are being changed and new files are added to the local repository. To save the changes in the git repository:

Download all the other changes from the remote repository to the local repository.

git pull

Changes have to be staged for the commit.

git add .

or

git add file_name

Now commit the staged files.

git commit -m "commit_name"

Push the changes.

git push origin master

Pushing Changes to GitBash

New changes can be seen:

Updated Directory

Create and Manage Branches in GitBash

In a team workflow, each member works on a separate branch, and validated changes are merged into the main (master) branch. This branch-based workflow enables version control, parallel development, and easier source code maintenance.

**Syntax

git branch

git branch branch_name

git branch -d branch_name

git branch -D branch_name

git checkout -b new_branch_name

git checkout branch_name

After checkout to the branch, you can see a * on the current branch Now the same commit add and commit actions can be performed on this branch also.

new branch

Git Bash

Merging Branches in GitBash

First, reach the target branch

git checkout branch_name

Merge the branch to target branch

git merge new_branch

Cloning Repositories in GitBash

Cloning is used to get a copy of the existing git repository. When you run the git clone command it makes the zip folder saved in your default location

git clone url

This command saves the directory as the default directory name of the git repository To save the directory name as your custom name an additional argument is to be passed for your custom name of the directory

git clone url custom_name

Undoing Commits in GitBash

When there is a situation when you forget to add some files to commit and want to undo any commit, it can be committed again using --amend

**Syntax:

git commit --amend