-
Install Homebrew (if you don't have it already): Open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Install Git: Run the following command in Terminal:
brew install git
- Open Terminal and run:
xcode-select --install - Follow the on-screen instructions to complete the installation.
-
Set your name and email:
git config --global user.name "Your Name"git config --global user.email "your.email@example.com" -
Check the configuration:
git config --list
-
Create a GitHub account: If you don't already have one, sign up at github.com.
-
Generate an SSH key:
ssh-keygen -t ed25519 -C "your.email@example.com"
Press Enter to accept the default file location, and set a passphrase if desired.
-
Add the SSH key to your GitHub account:
- Copy the SSH key to your clipboard:
pbcopy < ~/.ssh/id_ed25519.pub
or
cat ~/.ssh/id_ed25519.pub
- Go to your GitHub account settings, navigate to SSH and GPG keys, and click New SSH key. Paste the key and give it a title.
-
Test your SSH connection:
ssh -T git@github.com
You should see a success message.
- Clone a repository:
git clone git@github.com:username/repository.git
-
Check status:
git status
-
Add changes:
git add .
-
Commit changes:
git commit -m "Your commit message"
-
Push changes:
git push
Following these steps will set you up with Git on your Mac and enable you to interact with remote repositories.