# Setting up Git and GitHub

{% hint style="danger" %}
It is very important that these steps are done correctly so that you can follow along!
{% endhint %}

## Installing Git

You will need to [install Git on your local machine](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).

## Configuring Git

{% hint style="info" %}
This guide assumes that you are using Git Bash (for Windows) or the terminal (for macOS and Linux), as we will be using Bash commands.\
\
If you are facing issues running certain commands (especially on Windows), please consider using Git Bash instead.
{% endhint %}

To ensure that Git installed correctly, run the following command:

```sh
git version
```

You should see a line of output like this:

```
git version 2.54.0
```

Once Git is installed on your local machine, tell Git who you are:

```sh
git config --global user.name '<your full name>'
git config --global user.email '<your email address>'
```

Then, tell Git about your preferred default code editor:

```sh
git config --global core.editor '<editor executable>'
```

For example, to use Visual Studio Code as your default editor for Git, replace `<editor executable>` from above with `code --wait` :

```sh
git config --global core.editor 'code --wait'
```

## Setting up GitHub

[Create a new GitHub account](https://github.com/signup) if you don't have one.

{% hint style="warning" %}
Make sure that the email address used for your GitHub account is the **same** as the one configured in Git!

Check the current email address configured in Git with:

```sh
git config --global user.email
```

If they differ, re-configure Git to use your GitHub email address:

```sh
git config --global user.email '<your github email>'
```

{% endhint %}

Then, connect Git to GitHub with SSH:

1. [Generate a new SSH key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key)
2. [Add the SSH key to GitHub](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account#adding-a-new-ssh-key-to-your-account)

To verify that your SSH connection to GitHub is working correctly, refer to [this GitHub documentation](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection), or run the following command:

```sh
ssh -T git@github.com
```

You should see output like this:

```
Hi <username>! You've successfully authenticated, but GitHub does not
provide shell access.
```

Congrats! You have successfully installed Git, and configured it to connect to GitHub on your local machine! 🥳


---

# 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://wiki.nushackers.org/orbital/git/setup.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.
