---
# System prepended metadata

title: Github Organizations and Git Workflow

---

# Github Organizations and Git Workflow

# Setting up Your Github Org

Please follow the below instructions to set-up your Github organization and repo (note: only one person per team needs to do this).

## Creating a Github Organization

1. Go to [github](https://github.com)
2. Click the "+" button in the upper righthand corner
3. Select "New organization" from the dropdown
4. Select the free tier
5. Input a name for your organization (eg graceshopper-team-awesome)
6. Input your personal email, select "My personal account", and click "Next"
7. Add all your teammates to this organization by searching for their Github usernames. Please also add your fellow and your instructor (my username is nlane). *Note* you can add people after this step, so feel free to continue on if you're missing some usernames.
8. Click "Complete set-up"
9. No need to fill out this next page ("Welcome to Github"). You can scroll to the bottom and click "Submit".

## Creating and Initializing your repo

1. Go to your organizations homepage (eg https://github.com/graceshopper-team-awesome)
2. Select the green button "Create a new repository"
3. Enter the name of your repository (eg graceshopper-project)
4. Select "Public" for the visibility
5. Select "Create Repository" (create a blank repo, do not check any boxes that add default files).
6. Copy the URL of your repo and clone it to your local machine: `git clone https://github.com/YOUR-PROJECT-URL.git`
7. `cd` into your new repo's folder
8. Follow the instructions from the [Boilermaker repo](https://github.com/FullstackAcademy/boilermaker) where you will be instructed to run these commands:
  ```
  git remote add boilermaker https://github.com/FullstackAcademy/boilermaker.git
  git fetch boilermaker
  git merge boilermaker/master
  ```
9. Run one more command: `git push origin master` or `git push origin main`
10. Refresh your Github page and you should see your repo initialized with the boilerplate code.

## Protect your Master Branch

1. From your repo's github page, select "Settings" (rightmost option under the repo name)
2. On the sidebar, select "Branches"
3. Click "Add rule"
4. Put `master` in the text field for "Branch name pattern"
5. Select two checkboxes: "Require pull request reviews before merging" and "Include administrators".
6. Finish by selecting "Create"


# GitHub Workflow

## Feature Branches

High level overview: pull latest main, make a branch, commit changes, push to GitHub, make a PR, get it approved, merge it to main. Rinse and repeat.

1. Make issue corresponding to feature
2. `git checkout main`
3. `git pull` to get main up to date
4. `git checkout -b YOUR-NEW-BRANCH-NAME` to switch to a new branch
5. Make commits for a given feature.
  - Use semantic commit messages: `type(scope): message` e.g. `feat(client): switch to React-Redux`
  - Keep commits related to that feature branch. If you need to make other commits, **go back to main**, make a new branch, add those separate commits etc.
6. When you are done, `git push -u origin YOUR-NEW-BRANCH-NAME`
7. Navigate to GitHub
8. Select "open pull request"
9. Refer to any issues the PR will close, e.g. `Closes #32, closes #46`. You need to use "closes" for each issue separately.
10. Request a review
11. Address review comments by pushing more commits
12. When all checks pass, merge to `main`
13. On your local machine, `git checkout main`
14. `git pull`
15. Start the cycle again

## Merge Conflicts

GitHub has an online merge conflict resolution tool, but you _can_ and _should_ learn how to fix merge conflicts locally too.

1. On your local machine, `git checkout main`
2. `git pull`
3. `git checkout YOUR-FEATURE-BRANCH`
4. `git merge main`
5. `git status`
6. Find all conflicts and fix them manually. Collaborate / communicate with teammates to decide how best to do so!
7. `git add -A`
8. `git commit`
9. `git push`
10. Check that the PR now has no conflicts.
