Week 2 - Programming basics

JavaScript

Basic Syntax

Variables

Data types

Numbers

Basic IO

Conditionals

Nested conditions

Git branches

GUI Tools for Git

Code style: Basics

Introduction to AI

Practice

Assignment

Back to core program

Branches are a core feature of Git. A branch allows you to work on a different "version" of your project. Take a look at the following image:

image.png

<aside> ❗

Git branching and merging is a complex topic that requires practice. It's normal to feel lost at the beginning, but you'll improve with time and experience.

</aside>

The default branch

When you create a new Git repository, it comes with a default branch. This is usually the primary branch where your code lives, and it's often the branch that is published to the users. In older versions of Git, this default branch was called master. However, in newer versions, it's called main.

Watch: Branching Tutorial

<aside> 💭

Watch the first 11:30 minutes of the video below - Stop watching, right before the ‘Merging’ topic

</aside>

Git Branching and Merging - Detailed Tutorial

Key takeaways so far:

<aside> ⌨️

Hands on:

  1. Create a new Git repository
  2. Create a file and commit it to the default branch
  3. Create a new branch
  4. Make changes to the file and commit
  5. Return to the main branch
  6. Inspect the file. What happened to the recent changes?
  7. Return back to the other branch and inspect the file again </aside>

Merging

Merging is the process of combining changes from one branch into another. When we’ve completed work on a feature branch, we’ll typically want to merge those changes back into the main branch.

To merge a branch into your current branch, use the command git merge <branch-name>. For example, if you're on the main branch and want to merge changes from a feature branch, you would run git merge feature-branch.

Continue watching

<aside> 💭

Continue watching the previous tutorial from minute 11:31 until the end

</aside>

Git Branching and Merging - Detailed Tutorial

The video covered an important topic: "Feature branches workflow". Professional developers and companies use this process extensively, so it's important to practice it:

<aside> ⌨️

Hands-on: Practice a simple GitHub workflow:

  1. Create or clone a repository from GitHub
  2. Create a new branch, make a change, commit, and push
  3. Go to the repository on GitHub and create a pull request from your new branch to main
  4. Review the changes and merge the pull request by clicking the green button
  5. Inspect the merged changes on GitHub
  6. Return to your terminal. You're still on the feature branch—switch to the main branch
  7. Pull the latest changes from GitHub
  8. Inspect the local files and verify they contain the changes
  9. Delete the new branch locally and remotely </aside>

Extra materials


The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 **

CC BY-NC-SA 4.0 Icons

*https://hackyourfuture.net/*