Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.obsidian/**
.obsidian
.obsidian
.trash
8 changes: 0 additions & 8 deletions .trash/04-repl-vs-script.md

This file was deleted.

5 changes: 5 additions & 0 deletions curriculum/03-git-basics/01-introduction-to-git.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ isDraft: true
# Introduction to Git
## Introduction
First let's make things clear, **Git** and **Github** are two completly separate systems. We usually use both together and in this lesson we will talk about what is **Git** and what is **Github**. I the next lesson we will connect those two together and in the last lesson of the chapter, we will learn the basics of using **Git**.

## What is Git?
You can think of `git` as a really awesome save button, but instead of saving files like code editor does (one copy at a time), `git` tracks diffrences between the files. This allows us to version control our programs, revert back in time when we brake something and have a clean history of how the project evolved. Knowing how to use `git` is another essential skill to have as a developer.

Git is local only software (program) that enables all of these cool features. It runs completly offline and does not contact any servers by default.

## What is Github?
Github is an online platform that enables hosting our `git`-s to remote servers, collaborate more easily with fellow developers and ultimately be your own porfolio.

Github is under Microsoft domain which some developers don't like, so there are more alternatives like *gitlab*, *bitbucket*, etc ... For the purpose of this course we will be using Github.

## What's Next
In the next lesson, we are going to set up Git and connect it to Github so those two can talk to each other securely.

113 changes: 113 additions & 0 deletions curriculum/03-git-basics/02-setting-up-git-and-github.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
id: setting-up-git
title: Setting up Git and Github
sidebar_label: Setting up Git & Github
sidebar_position: 2
lesson: true
---
# Setting up Git and Github
## Introduction {#introduction}
Learning `git` is very important as we mentioned before, and you will become very much familiar with it. Don't stress out about the current lesson too much, the goal is to set you up, as we will cover more `git` in feature lessons.

## Lesson Overview {#overview}
In this lesson you will learn:
* What exactly is Git
* What exactly is Github
* Install and configure `git`
* Create Github account
* Connect Git to Github

## Installing Git
Follow guide on installing `git` depending on your own operating system (**Note:** These are external resources until we make our own guides). Only follow installation instructions for now, do not yet configure it.
* [Linux](https://ubuntu.com/developers/docs/explanation/use-vcs/#getting-git)
* [MacOS](https://www.freecodecamp.org/news/setup-git-on-mac/)
* [WSL2](https://www.git-tower.com/blog/git-wsl#configuring-git)

## Make Github Account
Go to [github.com](https://github.com/) and create an account. You will need a valid email where GitHub can contact you in the feature. This will also be default for identifying your contributions.

:::note[If you are woried about privacy]

If you don't want to have sign-up email listed in your contributions, there is an option to hide it **after** you log in.

In **Email Settings** page, set these two options to **ON**.
* Keep my email address private
* Block command line pushes that expose my email
This will prevent your email from leaking from your contributions. If you wish so, you can use the email generated for you by Github, which is shown in **Keep my email address private** section. Make sure you note it, as you will need it in the next steps.

:::

### Set up 2FA (Optional)
To set up 2-factor auth, follow [Configuring two-factor authentication](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/configuring-two-factor-authentication).

## Connect Git with Github
For `git` to work as intended, you need to provide the credentials it can use to represent your local user (you) to Github.

### Who Are You
First, we need to tell Git what is your username and password. Enter the below commands, one by one, but make sure you provide your own (Github) username and email (be it your personal one you registered for account on Github or Github generated one).
```sh
git config --global user.name "Your Name"
git config --global user.email yourname@example.com
```

### Change Default Branch
Github changed the name of the default branch from `master` to `main` so let's reflect that with this command:
```sh
git config --global init.defaultBranch main
```

## Verify Your Inputs
Before next steps, we should check if we have done everything good. Run these commands one by one and see if they match your information.
```sh
git config --get user.name
git config --get user.email
```

### Create SSH Key
SSH key is cryptographically secure identifier, like a long password used to identify your device. Github uses SSH keys to allow you access to your repositories without asking for a password each time.

First, let's make sure you have *ed25519* algorithm already installed. Run the following command:
```sh
ls ~/.ssh/id_ed25519.pub
```
If an error apears stating **No such fule or directory** then you do not yet have required key and you need to generate one. If no such message appears, you can proceed to the next step.

To create a new SSH key run the following command:
```sh
ssh-keygen -t ed25519
```
When it asks for the location, just press <kbd>Enter</kbd> for the default location.

Next it will ask for a passphrase; this is like a password for SSH key stored on your machine and you will be asked for it on each use of SSH key. If you do not use passphrase your SSH key will not be encrypted and can be seen or modified with other users of your machine. Enter one if you wish but it is NOT required to do so.

If you choose a passphrase enter it, or if you dont wish to use it, leave it blank and just press <kbd>Enter</kbd>.

### Tell Github Your SSH Key
Now we need go tell Github what is your SSH key. Open Github webpage, then click on your profile picture (top right corner), then `Settings`, then `SSH and GPG keys`. Then click on the green button that says `New SSH Key`.

Give your key some descriptive name, so you will know it belongs to that machine, and leave the window open while you complete the next steps.

Now we need to copy our public half of SSH key. To do this we are going to use that `cat` command we mentioned in the **Command Line** lesson. Open your terminal and run the following command:
```sh
cat ~/.ssh/id_ed25519.pub
```

Select and copy **whole** output of the command, if you followed the instructions above, the output will probably start with `ssh-ed25519` and end with `username@hostname`.

Now go back to Github window and paste the copied SSK key into the key field. Keep the key type as `Authentication Key` and finally click `Add SSH key`.

You are done, you have successfully connected your local Git with remote Github. All that is left to do is test the connection.

### Test Connection
Test your SSH key by following [GitHub’s directions for testing your SSH connection](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection?platform=linux). Make sure the fingerprint output in the terminal matches [one of GitHub’s four public fingerprints](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints).

You should see this response in your terminal:
```
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
```
Don’t let GitHub’s lack of providing shell access trouble you.

If you see this message, you’ve successfully added your SSH key and you can move on. If the output doesn’t correctly match up, then try going through these steps again or come to our Discord server to ask for help.

## What's Next {#next-lesson}
In the next lesson we take a look at basic `git` commands, what they do and we create our first repository, both local and remote, so let's jump right in!
10 changes: 0 additions & 10 deletions curriculum/03-git-basics/02-setting-up-git.md

This file was deleted.

43 changes: 41 additions & 2 deletions curriculum/03-git-basics/03-git-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,46 @@ title: Git Basics
sidebar_label: Git Basics
sidebar_position: 3
lesson: true
isDraft: true
---
# Git Basics
## Work in progress
## Introduction {#introduction}
Now that we have connected `git` with `github` we can learn some `git` basics.

Git comes with a lot of commands, and is extremly powerful software. For now, we will focus on a few basic commands that you will use daily.

We belive in learning by doing, so let's go in this direction and prepare yourself for the assignments when we start working with python code.

## Lesson Overview {#overview}
In this lesson you will learn:
* What are `git` specific terms
* How to create a local repository
* How to add files to be tracked by `git` and **commit** changes to those files
* How to create and connect remote repository (from *Github*) to your local repository, then pushing changes to remote repository.

## Learn How Git Speaks
Before starting with commands, it's useful to get to know ourself with some wording `git` uses:
* **Repository**: A folder for your project. Each `git` project is a **repository** (or **repo** for short).
* **Commit**: A snapshot of your code at the time of creating **commit**. Commits are what allow you to undo your changes to any older commit at any time.
* **Branch**: A parallel codebase for you to experiment with and build new features without affecting the **main** branch
* **Pull Request (PR)**: When work on the branch is finished, you issue a pull request to your *main* branch so changes can be *merged*.
* **Remote**: A copy of your repository NOT on your local machine (etc.: *Github*)

## Assignment {#assignment}
1. Choose a directory on your local computer where you will store all of your projects and `cd` into it. For example create a directory called `Projects` in your `Documents` directory. For the rest of the course, we will assume your `Projects` directory has the following path: `~/Documents/Projects`.
2. Create a new directory by executing `mkdir simple-python-shop`, then `cd` into it by executing `cd simple-python-shop`.
3. Initialize `git` repository by executing `git init` command. This tells `git` to start tracking for changes in our directory.
4. Let's create a `README.md` file as every good repository should have one. Open your code editor in that directory by executing `code .` command (**NOTE:** don't forget the `.` at the end of the command). Create a new file with the name `README.md` and write some content in it, like:
```
This is the start of my python journey!
```
Or whatever contents you want.
5. Let's check the status of our repository by executing `git status` command. You will see your `README.md` in the section **untracked files**. This means `git` knows about your file, but it's not part of the snapshot it will create, so let's fix that in the next step.
6. By executing `git add README.md` we say to `git` that we want to add that file to **staging area** which is like a space where git is aware of your files and which will be included in the snapshot (commit). Like saying a photographer to line up and frame the shot. Now we take the actuall snapshot (commit) in the next step.
7. Execute `git commit -m "Add README file with initial content"` command which tells `git` to make the actuall snapshot (or **commit**). `-m` stands for **message** and its **required** in *commit* command, and not supplying it will open your default terminal text editor to enter the message. Message should be short but descriptive note explaining what you changed and why.
8. Now let's upload our files to *Github* (or **push** the changes we made). First we need to create a repository in our *Github*. Go to [github.com/new](https://github.com/new) and enter the name for your new remote repository. You can use the same name as your local directory: `simple-python-shop`. Then choose visibility setting (public or private). **DO NOT** create files *Github* offers: *README*, *.gitignore*, *license*; we will do these manually. Click on the green *Create repository* button.
9. Github will offer varius ways of getting things done, but the main thing you should be looking for is the command starting with `git remote add origin`. Copy that whole line and paste it in your terminal (be sure you are in our current directory (`simple-python-shop`)). The line should look something like `git remote add origin https://github.com/your-username/simple-python-shop.git`. Execute the command to add our remote repository as **remote** to our current git repository, so we can **push** the changes we made to online repository.
10. Now run `git push -u origin main` to send files to your *remote* we just added in the previus step. The `-u` flag is used only **first time** you push to set up *tracking connections* so in later pushes, we can just do `git push`.
11. Check your *Github* for pushed code. You should see your `README.md` sitting there on your repository view. Congratulations! You’ve just mastered the fundamental workflow of Git and GitHub.

## What's Next {#next-lesson}
We are finally done with introductions and essential setup so we can start with python lessons. Let's learn.
Loading