Let's jump into using Git for the first time! These days, you don't have to use a terminal for all the nitty-gritty commands, but it's great to get your feet wet using your terminal.

In case you need to review what Git even is, head over here 👇

What is Git?

⌨️ Option 1: Using the Git CLI

Cal Poly recorded a great walkthrough of using Git for the first time.

Jump in at the 15 min mark ⏰ and follow along on your own machine!

https://www.youtube.com/watch?v=5jxJZEkNqOE

📄 Command cheatsheet

For branching

# Check out someone else's branch
> git checkout BRANCH_NAME

# Create your branch. Before doing so, it's best to switch to the "master" branch
# first, since this is where the "main" code of your repository is living
> git checkout master
> git checkout -b "name_of_branch"
# Push that branch up to GitHub so others can access it
# Fun fact: HEAD will always equal the name of your current branch!
> git push -u origin HEAD

<aside> 💡 Every once in a while, you'll need to checkout a teammate's branch on your machine. So, you might run get checkout BRANCH_NAME, but wait! Why is it saying the branch doesn't exist? That's because you haven't gotten the latest list of remote branches yet! If you run into this issue, just run git pull and try checking out the branch again.

</aside>

<aside> 💡 If you're working on a team, try to come up with a naming convention for your branches. One we encourage at Bits of Good is including your name, the "issue number" your resolving (don't worry about that for now), and 3-5 words on what the branch is accomplishing. For example: ben/25/update-varsity-menu-items

</aside>

For pushing your changes to your branch

# Initialize git in your project folder
> git init
# Mark all the modified files in your project folder as ready to save
> git add -A
# Alternatively, list one or multiple files you specifically want to push
> git add fancy-file.txt
# Create a save, or commit, message that explains what was changed
# BE DESCRIPTIVE!!!
> git commit -m "add 'hot dog' to Varsity menu UI"
# Push those changes up to the remote version of your project (probably on GitHub)
> git push

For getting changes off the remote

# For pulling in remote changes to your current branch
> git pull
# If you get a merge conflict issue, don't fear! Open up your VS Code and 
# head to the Git tab (the third one down on the sidebar)

✨ Option 2: Use the VS Code editor

<aside> 🚨 We recommend using this option after you're comfortable with the command line interface. We'll be using that scary terminal more in the future, so it's good to practice now!

</aside>

The VS Code editor offers a ton of shortcuts for Git commands, to the point that you almost never need to open the command line!

This video details absolutely everything you need to know about using Git in VS Code.