Git bash for windows

Greg Foster
Greg Foster
Graphite software engineer

Git Bash is a command-line interface for using Git for Windows, providing users with a Bash emulation to run Git commands with more flexibility and efficiency. This guide will cover the essentials of Git Bash, from downloading and installing, to package management and executing your first commands.

  1. Git download for Windows: To get started with Git Bash, download the latest version of Git for Windows from the official website git-scm.com. It is available for various Windows versions including Windows 10, Windows 11, and older versions like Windows 7 and Windows 8.

  2. Git install Windows: Run the downloaded .exe file to start the installation process. During installation, you will encounter various setup options. Default settings are typically sufficient for most users, but you can customize components and the default editor used for Git commands if necessary.

  3. Git Bash setup: Among the options during installation, you'll choose how Git is run in the command prompt. We recommend selecting the "Use Git from the Windows Command Prompt" option, unless you have specific additional Unix tools you want to install alongside Git Bash. You can always change this setting later.

After installation, you can access Git Bash through the Start menu or by clicking on the shortcut you created during installation.

Git Bash operates on a unix-like CLI environment, meaning that you navigate the terminal like you would on a unix system.

  • Navigating directories: Use cd <directory> to change your current directory.

  • Creating directories: mkdir <directory-name> creates a new directory.

  • Creating files: touch <file-name> creates a new file.

  • Checking Git version: git --version shows the installed Git version, helpful for ensuring you have the latest features and security updates.

Before you start using Git, configure your user name and email address:

Terminal
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"

These details are important because every Git commit includes this information in its metadata.

TIP: If you want to change either field temporarily, you can run this command later without the --global , which will set email and name in the scope of the current git project.

  1. Create a workspace directory: It’s good practice to store all of your git repos in the same top level directory. This keeps all of your repositories organized and easy to access. Create a directory named workspace in your home directory.

  2. Creating a repository (repo): Next navigate create a new folder inside of your workspace directory and run git init. This command creates a new Git repository and adds a few Git metadata files.

  3. Create a README: Create a README.md file to give your new git project a starting point. You can do this with the command touch README.md.

  4. Staging changes: Use git add <file> to stage the single README file or git add . to stage the entire directory, in the case you’ve created other files as well. For further info, please see this guide on how to use git add.

  5. Committing changes: Commit your staged changes with git commit -m "Your commit message". Commit messages should be meaningful, describing what changes were made and why.

  • Git clone: To copy an existing Git repository, use git clone <repository-url>. This is often the first step when contributing to a project or starting a new feature based on an existing codebase. For further info, please see this guide on cloning repositories.

  • Git push: After committing changes in your local repository, use git push origin <branch-name> to upload them to a remote repository.

  • Git pull: To update your local repository with changes from the remote, use git pull origin <branch-name>.

Git Bash can be customized in various ways, such as modifying the Bash profile for aliases or prompts. For Windows package management, we recommend Chocolatey, or you can use Git's included package management features for specific Git-related tools.

Git Bash documentation and help: For more detailed information and troubleshooting, refer to the official Git For Windows documentation or use git help <command> to get help for specific Git commands.

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2