# Github Basics
This document can serve as a reminder on how to use Github to save both individual and group projects, as well as a debugger if you are having problems with your Github. Scroll down for the assignment.
#### What is Github?
Github is a code hosting program that allows people to store their code in respositories. What this means is that it is essentially a cloud where you can save your work in, similar to Google Docs. The only difference is that you have to mannually save when you make changes to the code, Github does not automatically save your work.
In this assignment, you will learn how to use Github on individual projects and on group projects, as the process for saving your work is a little different for each.
## Individual Github Practices
When you have some changes in your code, you have to commit these changes to Github to make sure they save.
When saving your work, you have to enter three commands into the terminal:
:::info
git add -A
git commit -m"message"
git push
:::
`git add -A` : adds all the changes made to Github
`git commit -m"message"` : this adds a message to the commit for you to be able to track your process easier --- the message should be informative on what you are updating such as "finishing part 1" or "fixing this bug"
`git push` : actually saves your changes
> Make sure to do these chagnes every time you make significant changes to ensure you are saving your work!!
## Group Projects and Github
In group projects using Github, the repository does not automatically update changes like a Google Doc. Instead, if one person makes edits on their computer they have to push the changes to Github then the other person has to pull the changes before making more edits.
It is important to follow the following steps everytime you open the group repository to do work:
:::info
**After edits are made:**
git add -A
git commit -m"message"
git push
**When opening the repository:**
git add -A
git commit -m"message"
git pull
:::
When a member of the group is making changes to the repository, it should become a habit to `git pull` all of the previous changes before making any edits. This will ensure that your group will run into few merge conflicts. When you are done making edits, make sure to `git push` similarly to how you would in individual projects.
> If you don't follow this pattern you will run into merge conflicts that can be difficult to figure out.
:::warning
To mitigate merge conflicts, it is important to have good communication with your group. Let group members when you push new changes and when you are pulling to work on the repo to make sure that everyone is working with the most updated version of the code.
If you have good communication then you are less likely to have merge conflicts :)
::::
### How to deal with merge conflicts
If there is a merge conflict, this means that there were changes made on multiple computers without pushing/pulling the changes, so the code edited on both computers does not match.
When this happens, follow these steps to work through the error:
:::info
1) Figure out where the merge conflict is located
2) Choose one computer to fix the error
3) Push the corrected changes to Github
4) The other people in the group pull the changes from Github
5) Fix any additional merge conflicts and push the changes
6) All members pull from Github to ensure everyone has the same code
If there are more merge conflicts, repeat these steps until the code is the same for everyone
:::
# Assignment
## Part 1
With your group, create a text file titled `Poem`
Each member of the group is going to add a different line to the poem for a total of 15-20 lines. Each group member alternates writing a line of the poem. You cannot write two connsecutive lines of the poem on the same computer.
:::spoiler Hint
Remember to pull the repo before doing any work and push your changes every time you add a line to the poem!
:::
## Part 2
Create a `README` text file with your group.
This file will serve as your write up for your final project.
In your `README` answer the following questions:
1) What worked well in creating the poem together?
2) Did you have any challenges like merge conflits or other and how did you solve those problems?