**NOTE**: If you want to see our images/gifs much more clearly, remember to right click on them and `Open them in New Tab`. Thank you.
# Explaining Git & GitHub
> By Lance & Juan
## What is Git?
Git is a *local* **V**ersion **C**ontrol **S**ystem (VCS). It is used by programmers to keep track of their changes, and to collaborate with others.
Git stores data like a series of snapshots. Every time you `commit`, Git takes a "snapshot" of what your files look like at the time and stores a reference to the screenshots. Creating a history of what you have added, deleted, or altered. The history of your changes is stored locally and can be lost, but can be stored on the cloud using your favorite cloud-based hosting service we will be using GitHub.
## What is GitHub?
GitHub is a website that utilizes Git and allows users to collaborate and publicly share files.
On GitHub, you can create a project and invite other GitHub users to collaborate with you. The website utilized the command line to make updating quick and easy.
GitHub accounts are also public which makes them a great addition to a resume.
### Analogy
Think of a show or movie like Loki that has a timeline that has alternate branches. Git allows you to create branches which are kind of like deviations from the main timeline. In these repos you can make changes and test them without making changes to the main bracnh or main timeline. Once you like the changes, you can commit the changes to the main branch.

# Installing Git & making a GitHub Account
> By Justin & Rafael
## Git (Web)
If you'd want to download Git (Windows, MacOS, & Linux) via web, go [here.](https://git-scm.com/downloads) Instructions for install are provided there.
Follow the instructions that are according to your Operating System, if you need help, don't forget to ask us for help.
## Signing Up to GitHub
Go to github.com and create an account by entering your email address at the box at the main page, or by clicking on ```Sign Up``` on the top right corner.
* Create your account with your email and a password.
# Git & GitHub Integration
> By Justin
## User configuration on Git
*Assuming you have a GitHub Account:*
1. Open up your terminal
2. Type in the following commands to authenticate your GitHub account with local Git CLI (make sure they match!)
<pre>
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
</pre>
### Extra SSH Configuration
*(Required for Linux & Mac OS due to HTTPS support ended in 2022 for these opporating systems)*
1. Create a SSH key
<pre>
ssh-keygen -C "your.email@example.com"
</pre>
This will prompt you to enter a file to name and a passphrase, you can just press `Enter` multiple times if you don't want to specify a file or passphrase.
2. Add the SSH key
<pre>
ssh-add ~/.ssh/id_rsa
</pre>
3. Copy content from `~/.ssh/id_rsa.pub`
<pre>
cat ~/.ssh/id_rsa.pub
</pre>
This will display the content of the file, copy the content of the file by selecting the text and pressing `Ctrl + Shift + C`.
4. Paste the content onto your GitHub account
Go to your [SSH and GPG Keys](https://github.com/settings/keys) settings page:

Press `New SSH Key` and copy the content into the `Key` field:

5. Test your SSH Connection
<pre>
ssh -T git@github.com
</pre>
If it outputs *"Hi (Your Name)! You've successfully authenticated, but GitHub does not provide shell access"*, then you successfully made the connection.
Otherwise, panic.
6. If you can connect successfully to Github by SSH, then tell Git about your new way to connect to Github
<pre>
git config --global gpg.format ssh
</pre>
7. Once you've told Git about your new way to authenticate yourself to Github, we'll need to send our key as *proof* that we are who we are:
<pre>
git config --global user.signingkey <i>/PATH/TO/.SSH/KEY.PUB</i>
</pre>
* You can find your key in your home folder (the folder of your user) under the `.ssh` folder.
## Creating a GitHub Repository
The GitHub homepage should be your dashboard, so it should look similar to this:

Create your repository by clicking on the green ```New``` button next to ```Top Repositories```.
## Configuring your GitHub Repository
On the ```Create a New Repository``` page, you could find some setings to configure your repository.
The only **required** setting you must input would be the name of the repository.
The other options (Publicity of repository, README Inititalization, etc) can be configured to your liking (the descriptions for every option are provided below them).
# How to use Git
> By Rafael
Alright, now that you've created your own repository, we need to create a directory to use for *using* Git. Find a place to create a folder for your repository (should be similar to the name of your GitHub repository) and enter into the folder.
For Windows, you could click on your search bar in File Explorer and type `cmd` so that your Command Prompt could land on your repository easily.

For Macintosh & Linux, open up your terminal, and type in:
<pre>
cd <i>/path/to/your/repo/folder</i>
</pre>
---
Now we can actually begin setting things up!
## Initializing your Local Repository
We first need to initialize the directory for Git, so we'll type:
<pre>
git init
</pre>
## Creating a Remote
Once you've done that, we now have to connect our repository from GitHub to our local repository in our current folder.
We can do that by creating a *remote* (short for remote repository).
First we need to grab the HTTPS link to our repository at GitHub. So lets go back to where we left off in our successful creation of your repository and copy that.

Once you've gotten your link, go back to your terminal and create your remote using this command:
<pre>
git remote add origin <i><LINK OF REPOSITORY></i>
</pre>
* **NOTE:** ```origin``` is the default name of remote.
* **NOTE:** Linux & Mac OS users will have to copy the SSH link instead of HTTPS link
If it returns nothing, then that's what it's meant to do, no worries there.
## Creating a local branch
Although we have a remote, we also need a *branch* for that remote to push & pull files between your repository at GitHub and your local repository.
GitHub's default branch is called `main` so we'll create a local branch with the same name so they're paired up.
<pre>
git checkout -b main
</pre>
*NOTE: the `-b` flag creates the `main` branch*
Output:

## Creating and Staging your README file
Since we have nothing on our local repoistory to *commit*, then we'll create a README file.
<pre>echo "<i>your text here</i>" >> README.md</pre>
**NOTE:**
* ```echo``` is a terminal command that 'echoes' out any message provided next to it
* ```>>``` is a keyword that *adds* <code>"<i>your text here</i>"</code> to the latest line of the destination its going to. In this case, it's creating <code>README.md</code> <b>and</b> writing <code>"<i>your text here</i>"</code> to it.
## Sending your First Commit
If you looked at the files in your folder, you'll notice that ```README.md``` has now appeared in it. Now we'll have to tell Git to add ```README.md``` in order to ready our commit.
<pre>git add README.md</pre>
Once you've added your file, we can check the status of the file by executing:
<pre>git status</pre>

We can now prove that ```README.md``` is added into git and is ready to be sent to be commited.
## Sending your first commit in Git
By 'commiting' we tell Git & GitHub that we're confirming final changes to our repository for submission.
In order to commit on Git, you must tell Git the description of your change(s) made in your repository.
<pre>git commit -m "<i>your message here</i>"</pre>
In our case, we can say `"Added README.md"` as our message.
### For Windows Users:
You'll see this as your popup after commiting, so you can just sign in:

As a result, once authenticated, you'll be able to see the output in your terminal indictating that the your commit has been successful.

## Pushing your commit to your GitHub Repository
Once everything is set and you've commited your `README.md` file, you can finally 'push' or send your commit to GitHub by:
<pre>git push -u origin main </pre>
* `-u`: Add an upstream (tracking) reference to main.
And... if you see this: Congratulations! You've pushed your commit onto GitHub! Go and check your repository on GitHub!


# Activity (Story Game - Creative Writing)
> By Truc
## Preparation:
1. Make a group of 2-4 members
2. Initialize a Git repository.
3. Share the Repo with your team members assuming you know their `username` and `email address`

## Context:
An RPG style story. Let's start with:
If having trouble teaming up, try this link and pick the same/favorable zodiac animal to work with: [Link](https://drive.google.com/drive/folders/1ps4HphJy4SI3Ta4AaIvC8BhMtDHuvUVJ?usp=sharing)
1. Character:
a. Origin
b. Abilities
c. Weakness(es)
2. Challenges:
a. Devin
b. Elon Musk
c. Shrek
3. Stages:
a. Dungeon
b. UFC Cage
c. Paris
## Execution:
- Have each member design certain paths in the story.
- Members work on seperate files, commit their changes and push them to the repository.
- Encourage member to review each other's contributions and continue building upon the story until the time is up.
- Facilitate a discussion where each group shares their section of the story and how it connects with the overall narrative.
- Review the final story together as a group
- Exchange stage 3 with other groups. **DO NOT EDIT IT!**
- Share it with the club to have a good laugh.
# Extra Resources
> By Justin
## Documentation
- [Git](https://git-scm.com/doc)
- [GitHub](https://docs.github.com/en)
- [GitHub SSH Authentication Guide](https://jeffbrown.tech/github-ssh/)
### Other Git/GitHub Apps
- [Lazygit](https://github.com/jesseduffield/lazygit)
- [GitHub Desktop](https://desktop.github.com/)
- [GitLens VSCode Extension](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens)