Git Bash on Windows for workshop attendees

Git Bash on Windows for workshop attendees#

Important

This installation guide targets specifically those following one of the workshops we deliver. For a more throrough guide, please see [here] (resource pending)

How to install the Git Bash terminal on Windows#

Here we will be going through installing the Git Terminal on Windows. We will mostly be following the Carpentries installation guide found here, with some added support and further instructions

  1. Download the Git Bash for Windows installer here (choose the standalone installer, 64-bit should work for most modern PCs)

    ../_images/git-scm-download.jpg

    Important

    What follows in steps is largely copied from the Carpentries installation instructions with some minor tweaks to maintain consistency with current best practices [10]

  2. Run the installer and follow the steps below (for clarity I have included an animated GIF of the process below, your installation will take longer than what is reflected in the GIF):

    1. Click on “Next” four (this might be a different number depending on what version of Git for Windows his is) times (two times if you’ve previously installed Git). You don’t need to change anything in the Information, location, components, and start menu screens.

    2. From the dropdown menu, “Choosing the default editor used by Git”, select “Use the Nano editor by default” (NOTE: you will need to scroll up to find it) and click on “Next”.

    3. On the page that says “Adjusting the name of the initial branch in new repositories”, ensure that “Override the default branch name for new repositories” is selected. This will ensure the highest level of compatibility for our lessons.

      Note

      The initial and top-copy branch name master is now being phased out in favour of main. If you are following best practices, and one of the workshops we deliver, it is important that you choose Override the default branch name for new repositories

    4. Ensure that “Git from the command line and also from 3rd-party software” is selected and click on “Next”. (If you don’t do this Git Bash will not work properly, requiring you to remove the Git Bash installation, re-run the installer and to select the “Git from the command line and also from 3rd-party software” option.)

    5. Select “Use bundled OpenSSH”.

    6. Ensure that “Use the native Windows Secure Channel Library” is selected and click on “Next”.

    7. Ensure that “Checkout Windows-style, commit Unix-style line endings” is selected and click on “Next

    8. Ensure that “Use Windows’ default console window” is selected and click on “Next”.

    9. Ensure that “Default (fast-forward or merge)” is selected and click “Next

    10. Ensure that “Git Credential Manager” is selected and click on “Next”.

    11. Ensure that “Enable file system caching” is selected and click on “Next”.

    12. Click on “Install”.

    13. Click on “Finish” or “Next”.

      ../_images/git-installation.gif

Check your install#

  1. Check that everything was installed correctly:

    1. Open up Git Bash by clicking on Start () or search () and type “Git Bash

    2. Once Git Bash starts up type in the following commands to check that things are running smoothly:

      Home directory

      echo $HOME
      

      you should get

      /c/Users/<your-username>
      

      in response

      Shell type

      echo $SHELL
      

      you should get

      /usr/bin/bash
      

      in response

    3. Now, let’s check your Git commit editor is set up properly:

      Git commit editor

      git config --global --get core.editor
      

      if you get anything other than no response the type in the following:

      git config --global core.editor nano -w
      
    4. Let’s open up the config file in the default editor (nano) to check things are running smoothly:

      Open config file in default editor

      Type in the following:

      git config --global -e
      

      you should get a prompt to wait, after a few seconds the nano editor will then open up with your global configuration file. We’ve not set anything up yet so your configuration file might be blank. Press ctrl-X to exit.

      Note

      We will be setting our preferred editor in-lesson, so you will be able to choose your favourite!

    5. Just this one final step and you’ll be all set to follow along:

      Check SSH Key Generator is installed in Git Bash

      Type

      ssh-keygen --help
      

      If the response is the help menu then you’re all set!

    6. (Optional) Check if you have SSH Keys already set up

      Check for any pre-existing SSH Keys

      Type

      ls -la | grep '\.ssh\/'
      

      in Git Bash

      if the response is something like this then you do have pre-existing SSH Keys (don’t worry we will be setting keys for GitHub authentication in lesson!)

      ../_images/check-ssh.jpg

Search icon by Icons8