|
| 1 | +# Git |
| 2 | + |
| 3 | +## Verify if Git & GitHub are already installed: |
| 4 | + |
| 5 | +- In your terminal, run: `git config --list` |
| 6 | +- **Note**: To exit the git config --list screen, type the letter `q` in your terminal |
| 7 | + - *If the output is similar to:* |
| 8 | + |
| 9 | + - ```bash |
| 10 | + user.name=[Your name is here] |
| 11 | + user.email=[Your email is here] |
| 12 | + code.editor=code --wait |
| 13 | + init.defaultbranch=main |
| 14 | + ``` |
| 15 | + |
| 16 | + - Then move on to [next page](./5-tree.md) |
| 17 | + - *If output is not similar to the above*, continue with instructions on this page. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Install and Configure Git and GitHub |
| 22 | + |
| 23 | +Run the following command to ensure that you have the most recent version of git: |
| 24 | + |
| 25 | +`brew install git || brew upgrade git` |
| 26 | + |
| 27 | +## Setup GitHub for "Authentication" |
| 28 | + |
| 29 | +In order to use Git locally in a secure manner, we need to connect our computer with github.com. |
| 30 | + |
| 31 | +[GitHub Instructions: Caching GitHub credentials](https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git) |
| 32 | + |
| 33 | +- Install CLI by completing the following steps: |
| 34 | + - run in terminal: `brew install gh` |
| 35 | + - run in terminal: `gh auth login` |
| 36 | + - Use arrow key to select **GitHub.com** |
| 37 | + - Select **HTTPS** |
| 38 | + - When prompted with Authenticate Git with your GitHub credentials (Y / n). Press `y` and enter |
| 39 | + - Click **Login with a web browser** |
| 40 | + - Copy the one time code shown in yout terminal and then press enter. This will open github.com in a web page. |
| 41 | + - If not signed in, you will be prompted to signin. |
| 42 | + - Github will prompt you for the one time code. Enter in the appropriate boxes. |
| 43 | + - Click **Authorize github** |
| 44 | + - You can close the web browser and press enter in your terminal to continue. |
| 45 | + |
| 46 | +## Git Config |
| 47 | + |
| 48 | +Like artists, programmers sign their work. Let's configure Git to sign your commits with your name and email address. |
| 49 | +
|
| 50 | +**WARNING:** Before running the following commands one line at at time, replace `YOUR FULL NAME` and `YOUR EMAIL ADDRESS` with the name and email from [Your GitHub Account](https://github.com/settings/profile) |
| 51 | +
|
| 52 | +```bash |
| 53 | +git config --global user.name 'YOUR FULL NAME' |
| 54 | +``` |
| 55 | +
|
| 56 | +```bash |
| 57 | +git config --global user.email 'YOUR EMAIL ADDRESS' |
| 58 | +``` |
| 59 | +
|
| 60 | +```bash |
| 61 | +git config --global core.editor "code --wait" |
| 62 | +``` |
| 63 | +
|
| 64 | +```bash |
| 65 | +git config --global init.defaultbranch main |
| 66 | +``` |
| 67 | +
|
| 68 | +### [⇐ Previous](./3-homebrew.md) | [Next ⇒](./5-tree.md) |
0 commit comments