Git Installation on macOS
Installing Git on macOS
This guide walks you through installing Git on your macOS machine for use with RStudio and GitHub. I recommend using Homebrew for the easiest installation.
!! At LJMU managed computers, install Git either from Company Portal or App Player (older).
Method 1: Using Homebrew (Recommended)
Homebrew is a package manager for macOS that simplifies software installation.
- Install Homebrew (if not already installed)
Open the Terminal application:
Finder > Applications > Utilities > Terminal.Run the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Follow the on-screen instructions, entering your macOS user password if prompted.
- Install Git using Homebrew
In the Terminal, run:
brew install gitPress Enter to download and install Git.
- 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 --versionand press Enter. You should see the Git version (e.g.,git version 2.43.0).
Method 2: Using the Official Installer (Alternative)
- Download the Installer
- Visit the official Git website: https://git-scm.com/downloads.
- Click the “macOS” link and download the latest
.dmginstaller.
- Run the Installer
- Locate the downloaded
.dmgfile and double-click it. - Double-click the
.pkgfile in the opened window to start the installer.
- Locate the downloaded
- Follow the Installation Wizard Prompts
- Click
Continuethrough the steps. - Enter your macOS administrator password when prompted.
- Click
- 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 --versionand press Enter. You should see the Git version (e.g.,git version 2.43.0). ! If you want to copy and paste, but it doesn’t work with Ctrl + V or Cmd + V, use Shift + Insert, or Edit->Paste
RStudio, Git, and GitHub Workflow
To use Git and GitHub with RStudio, follow these steps:
- Start/Update Project: Create or update an RStudio project locally.
- Edit Code: Write or modify R code in RStudio.
- Save & Stage: Save changes and stage them with
git add. - Commit Changes: Commit staged changes with
git commit. - Push to GitHub: Push commits to a GitHub repository with
git push. - Sync with GitHub: Ensure the GitHub repository reflects local changes.
- Pull Changes: Pull updates from GitHub with
git pull.