How to Use Git Bash on Windows: A Beginner’s Tutorial

Git Bash is a powerful terminal environment that brings the Unix-style command line to Windows, letting developers run Git commands and shell scripts seamlessly. It’s an essential tool for version control on Windows, offering a familiar Linux-like experience without the need for a virtual machine.

To get started, install Git for Windows from the official website. Run the installer and accept the default settings. Once installed, right-click any folder and choose “Git Bash Here,” or search for “Git Bash” in the Start menu to launch it.

Article illustration

Navigating Directories

Git Bash uses Linux-style navigation commands:

  • pwd – Shows your current directory path.
  • ls – Lists files and folders.
  • cd folder-name – Changes into a directory.
  • cd .. – Moves up one level.
  • mkdir new-folder – Creates a new folder.

Basic Git Commands

Here’s a quick version control workflow:

  • git init – Starts a new repository in the current folder.
  • git status – Checks the state of your files.
  • git add . – Stages all changes for commit.
  • git commit -m “message” – Commits staged changes.
  • git log – Shows commit history.

Working with Remote Repositories

Sync with GitHub or GitLab using these commands:

  • git clone URL – Downloads a remote repository.
  • git remote add origin URL – Links a local repo to a remote.
  • git push origin main – Uploads your commits.
  • git pull – Fetches and merges remote changes.

Mastering Git Bash takes practice, but these core commands will have you productive in no time. Start with navigation, then experiment with the Git workflow until it becomes second nature.

sarah antaboga
Author: sarah antaboga

Leave a Reply

Your email address will not be published. Required fields are marked *