# Git Installation

### Cornell GitHub

You can access the Cornell GitHub enterprise [here](https://github.coecis.cornell.edu/).

### Install Git *(skip this step if you already have Git installed)*

To check to see if you have git installed, open **Terminal** and run `git --version`. A message will display if you already have it installed.

Follow the instructions [here](https://git-scm.com/download/mac) to install Git. I personally recommend using the **Homebrew** approach (requires you to install [Homebrew](https://brew.sh/)), but the Binary Installer should work as well.

### Generate SSH Key

1. Log in to your GitHub. Go to **Settings > SSH and GPG Keys**. Create a **New SSH key**.
2. Keep the page open. Open up **Terminal** and execute the two commands (replace **YOUR NAME** and **YOUR GITHUB EMAIL**):

   `git config --global user.name "YOUR NAME"`

   `git config --global user.email "YOUR GITHUB EMAIL"`
3. To generate an SSH Key, type `ssh-keygen -t ed25519 -C "YOUR GITHUB EMAIL"`
   1. Press ***enter*** when asked: **“Enter file in which to save the key”**.
   2. If asked “***\[…]*****/.ssh/id\_ed25519 already exists. Overwrite (y/n)?”**, type ***y*** and press ***enter***.
      1. **Note:** If you have previously configured SSH authentication for other services, overwriting your current key will likely cause you to lose access. You will need to reconfigure that service to authenticate using the *new* key in order to regain access.
   3. When asked: “**Enter passphrase (empty for no passphrase):**” just press ***enter***.
   4. When asked: “**Enter same passphrase again:**” just press ***enter***.
   5. Copy the generated key to your clipboard by typing `pbcopy < ~/.ssh/id_ed25519.pub`
4. Go back to the GitHub page from earlier. For the **Title** field, I recommend putting the name of your device (such as “Vin’s Macbook”). The key type is **Authentication Key**. Paste the generated key, then click **Add SSH key**.

### Configure SSH Agent

For **newer Macs** (12, Monterey/Ventura), run

`ssh-add --apple-use-keychain ~/.ssh/id_ed25519`

* If that command fails, try `ssh-add --apple-use-keychain ~/.ssh/id_rsa`

For **older Macs (11, Big Sur)**, run `ssh-add -K ~/.ssh/id_ed2551`

* If that command fails, try `ssh-add -K ~/.ssh/id_rsa`

### Cloning a repository (not needed for installation)

Open up **Terminal** and change the directory to wherever you want the repository files to be located. You can change the directory using the `cd` command.

* For example, if I want the repository files to be located in my Desktop, I would type `cd Desktop`

```powershell
(base) vinnie@dhcp-vl2041-37760 ~ % cd Desktop 
(base) vinnie@dhcp-vl2041-37760 Desktop %
```

To clone a repository, simply type `git clone <ENTER URL HERE>`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ios-course.cornellappdev.com/resources/textbook/git-+-github/git-installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
