2 min read

Managing Git Repositories on macOS Tahoe

Git is the industry-standard version control system. macOS Tahoe integrates well with Git, especially when combined with the Zsh terminal.

Installation

macOS often comes with a version of Git installed (part of the Xcode Command Line Tools), but it is recommended to install the latest version using Homebrew to ensure you have the most recent features and security patches.

If you haven't set up Homebrew yet, refer to Package Management with Homebrew on macOS Tahoe.

To install the latest Git:

brew install git

Verify the installation:

git --version

Configuration

Before using Git, you must configure your identity. This information is embedded in every commit you make.

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

macOS Keychain Integration

macOS Tahoe can securely store your Git credentials (usernames, passwords, personal access tokens) in the system Keychain, so you don't have to type them every time you push to a remote repository.

Check if the helper is already configured:

git config --global credential.helper

If it returns osxkeychain, you are set. If not, enable it:

git config --global credential.helper osxkeychain

Basic Workflow

Initializing a Repository

To start tracking a project:

cd ~/Projects/my-project
git init

Cloning a Repository

To download an existing repository from a remote source (like GitHub or GitLab):

git clone https://github.com/username/repo.git

Staging and Committing

  1. Check Status: See which files have changed.
    git status
  2. Stage Files: Prepare files for a commit.
    git add .
  3. Commit: Save the snapshot with a descriptive message.
    git commit -m "Initial commit"

Visualizing History

You can view the commit history directly in the terminal:

git log --oneline --graph --all