How to Use Git Bash in Windows: A Beginner’s Guide

If you’re working with Git on Windows, Git Bash is one of the best tools to interact with Git repositories using familiar Unix-style commands. It offers a powerful terminal experience that supports most Linux commands, making Git workflows smoother for developers.

In this guide, you’ll learn how to install, open, and use Git Bash on Windows to manage your Git projects effectively.


✅ What is Git Bash?

Git Bash is a terminal emulator for Windows that provides a Bash command-line interface and Git commands. It comes bundled with the official Git for Windows installer, allowing you to run Git and Linux-style commands on a Windows machine.


Step 1: Install Git Bash

  1. Download Git for Windows from git-scm.com.
  2. Run the installer and follow the prompts.
  3. When prompted for Adjusting your PATH environment, select Git from the command line and also from 3rd-party software.
  4. Choose Use Git Bash only or Use Windows’ default console window (Git Bash is recommended).
  5. Complete the installation.

Step 2: Open Git Bash

  • After installation, open Git Bash by:
    • Searching Git Bash in the Start menu and clicking the app.
    • Right-clicking inside any folder in File Explorer and selecting Git Bash Here to open a terminal in that folder.

Step 3: Basic Git Bash Commands

Here are some essential commands to get started:

CommandDescription
pwdPrint current directory
lsList files and folders
cd <folder>Change directory
git clone <repo-url>Clone a remote Git repository
git statusShow changes in the repo
git add <file>Stage file(s) for commit
git commit -m "msg"Commit changes with a message
git pushPush commits to remote repository
git pullFetch and merge changes from remote
exitClose Git Bash

Step 4: Using Git Bash for Git Workflow

A typical Git workflow in Git Bash might look like this:

# Clone a repo
git clone https://github.com/username/repo.git

# Navigate into the repo folder
cd repo

# Check repo status
git status

# Stage changes
git add .

# Commit with message
git commit -m "Your commit message"

# Push changes to remote
git push

Step 5: Customize Git Bash (Optional)

  • Change appearance by right-clicking the Git Bash title bar → Options.
  • Add aliases for commands in the .bashrc file for faster workflows.
  • Use Git Bash inside Visual Studio Code terminal for an integrated experience.

🧠 Tips for Windows Users

  • Use Git Bash over Windows Command Prompt for a richer Git experience.
  • Git Bash supports many Linux commands, so you can use familiar shortcuts like grep, cat, and ssh.
  • Remember to run Git Bash as administrator if you encounter permission issues.

Conclusion

Git Bash brings the power of Unix-like Git commands to Windows, making it easier and more efficient to manage your repositories. Whether you’re a beginner or an advanced user, Git Bash is a must-have tool for your Windows development environment.

Sharing Is Caring:

Leave a Comment