Git Basics for the Serverless Camp
Tags: serverless, javascript, webdev, programming
Published: 2021-02-26 11:39:11

Before we start working on anything, we want to make sure to clone this repository so that you can easily edit your work and make pull requests locally.

First time connecting with GitHub from your computer? Check out this website on [Connecting to GitHub with SSH](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)

[Cloning A Repository](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)

Prepare:
1. Open Visual Studio Code (VS Code) on your computer
	* We will be using VS Code as our code editor
2. Open a new terminal (top menu > Terminal > New Terminal)

Run the following commands in the terminal to create a space for your work in Camp.Dev:
1. `pwd` to "print working directory" (check the name of the directory/folder you are currently working in)
2. `ls` to see what's inside this directory
3. `mkdir Camp-Dev` (make directory) to create a new directory for all your Camps
4. `cd Camp-Dev` to "change directory" (move) into the new folder that you just created

Run the following commands in the terminal to clone the repo:
1. `git init` to initialize the repository
2. `git clone [link-to-repo]` to create a copy of this repo on your device
3. `ls` to check the name of the folder that you just cloned
4. `cd [folder-name]` to "change directory" (move) into the new folder that you just cloned
5. `git branch` to check which branch you're currently in (should say either `main` or `master`)
6. `git checkout -b w1s1` (w1s1 = week 1 step1) to **create a new branch** (this should automatically move you to the new branch you create)
7. Optional: `git checkout w1s1` to change branch to w1s1 (you can use this command when you have previously made a branch and don't need to create a new one)

This is what your terminal should look like:

![git init](https://user-images.githubusercontent.com/28051494/109287346-4c333e00-77d8-11eb-9575-072a88ea7ded.png)

![git clone](https://user-images.githubusercontent.com/28051494/109287355-4dfd0180-77d8-11eb-84fc-bce5e2d6259c.png)

![move into cloned repo](https://user-images.githubusercontent.com/28051494/109287364-505f5b80-77d8-11eb-82e7-1b39bf1e8d86.png)

# How to make a Pull Request

1. `git branch` to check which branch you're in
2. `git pull` to pull any updates from the remote (online) repository (repo)
3. `git checkout w1s1` if you're in main, move to w1s1 for week 1 step 1 with (or the name of the branch you were editing in)
3. `git add notes.md` to add the files you were editing
	* `git add .` will add all the changed files including all new ones (use this when you edit or add multiple files to save time)
4. `git commit -m "[your-commit-message]"` change [your-commit-message] to specifically what changes you are committing
	* make sure there are no errors in this step
	* if there are errors and you're not sure how to proceed, reach out to an instructor on the [Bit Project Discord](join.bitproject.org)
5. `git push` to push all changes to the remote repo

	![push changes](https://user-images.githubusercontent.com/28051494/109290907-180e4c00-77dd-11eb-93ba-cee576b24b2c.png)
6. go to the github website and check to see if it updated notes.md with the changes you made on your computer
7. click on the button that says: "Compare & Pull Request"

	![compare and pull request](https://user-images.githubusercontent.com/28051494/109290914-193f7900-77dd-11eb-9d09-73d5aa6b43be.png)
8. leave a comment stating which specific step this PR is for
9. create the pull request
	* if there are any merge conflicts and you're not sure how to proceed, reach out to an instructor on the [Bit Project Discord](join.bitproject.org)

	![comment and create](https://user-images.githubusercontent.com/28051494/109291023-468c2700-77dd-11eb-8137-a85d0c20fe89.png)

</details>