Git Installation on Windows

Installing Git on Windows

This guide walks you through installing Git on your Windows PC for use with RStudio and GitHub.

!! At LJMU managed computers, install Git either from Company Portal or App Player (older).

  1. Download the Installer
  2. Run the Installer
    • Locate the downloaded .exe file (e.g., Git-2.xx.x-64-bit.exe) and double-click to start the installation wizard.
  3. Follow the Installation Wizard Prompts
    • License: Click Next.
    • Select Components: Accept defaults, ensuring “Git Bash Here” and “Git GUI Here” are checked. Click Next.
    • Installation Location: Use the default location unless needed otherwise. Click Next.
    • Start Menu Folder: Accept the default. Click Next.
    • Adjust PATH Environment: Critical for RStudio. Select:
      • “Git from the command line and also from 3rd-party software”
      • Click Next.
    • Default Branch Name: Use main for new repositories. Click Next.
    • HTTPS Backend: Choose “Use the OpenSSL library” (recommended). Click Next.
    • Line Ending Conversions: Select “Checkout Windows-style, commit Unix-style line endings” for cross-platform compatibility. Click Next.
    • Terminal Emulator: Choose “Use MinTTY (default Git for Windows terminal)”. Click Next.
    • Default git pull Behavior: Select “Default (fast-forward or merge)”. Click Next.
    • Credential Helper: Choose “Git Credential Manager Core”. Click Next.
    • Extra Options: Accept defaults. Click Next.
    • Experimental Options: Uncheck unless needed. Click Install.
  4. Finish Installation
    • Click Finish when complete. Uncheck “View Release Notes” if desired.
  5. Verify Installation in RStudio
    • Important: Close and reopen RStudio (or its terminal pane) to update the PATH environment variable.

    • Open a new terminal in RStudio: Tools > Terminal > New Terminal.

    • Type git --version and press Enter. You should see the Git version (e.g., git version 2.45.2.windows.1).

      ! If you want to copy and paste, but it doesn’t work with Ctrl + V or Cmd + V, use Shift + Insert, or Edit->Paste

    • If an error occurs, restart your computer and retry git --version.

RStudio, Git, and GitHub Workflow

To use Git and GitHub with RStudio, follow these steps:

  1. Start/Update Project: Create or update an RStudio project locally.
  2. Edit Code: Write or modify R code in RStudio.
  3. Save & Stage: Save changes and stage them with git add.
  4. Commit Changes: Commit staged changes with git commit.
  5. Push to GitHub: Push commits to a GitHub repository with git push.
  6. Sync with GitHub: Ensure the GitHub repository reflects local changes.
  7. Pull Changes: Pull updates from GitHub with git pull.

Proceed with GitHub Complete workflow | Return to Section Overview