Skip to content

Commit

Permalink
Merge pull request #233 from john0isaac/main
Browse files Browse the repository at this point in the history
Adding Introduction to Git, GitHub, and Version Control workshop
  • Loading branch information
leestott authored Sep 18, 2023
2 parents ab1b6f3 + 8a6b7b9 commit 8547a4c
Show file tree
Hide file tree
Showing 8 changed files with 365 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Welcome to the [Next Generation Team's Workshop Library](presentation.pptx), bui
2️⃣ | [Get Started with Django](./full/django-get-started/README.md) | Christopher Harrison | 1-1.5 hours | Build a web app with Django | [🎥](https://youtu.be/H3dDiVNY_ks) | Python, [Get started with Django](https://docs.microsoft.com/learn/modules/django-get-started/?WT.mc_id=academic-56601-chrhar)|
2️⃣ | [Build a Mood Journal Progressive Web App](./full/mood-journal-progressive-web-app/README.md) | Beth Pan | 1.5 hours | Build a Mood Journal for Mental Health as a Progressively-Enhanced Web app | [🎥](https://youtu.be/12THeQreSQ0) | JavaScript|
2️⃣ | [Build an API with Data API Builder for your Static Web Apps](./full/smart-shopping-planner-app/README.md) | Julia Muiruri | 1 hour | Smart Shopping Planner is a React project, that uses an Azure SQL database and uses Data API Builder to provide REST endpoints to connect to the database. | [🎥](https://youtu.be/9N1Z9KPbeEY) | JavaScript, Data API Builder (Static Web Apps database connections)|
1️⃣ | [Introduction to Git, GitHub, and Version Control](./full/intro-git-github-version-control/README.md) | [John Aziz](https://github.com/john0isaac/?wt.mc_id=studentamb_71460) | 1 hour | Fundamentals of Version Control, Setting Up Git, Working with Local Repositories, Working with GitHub | | [Introduction to version control with Git](https://learn.microsoft.com/training/paths/intro-to-vc-git/?wt.mc_id=studentamb_71460), [Microsoft Learn for GitHub](https://learn.microsoft.com/training/github/?wt.mc_id=studentamb_71460) |

---
<details>
Expand Down
55 changes: 55 additions & 0 deletions full/intro-git-github-version-control/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Introduction to Git, GitHub, and Version Control

## Goals

In this workshop, we will discuss the concept of version control which is the foundation of understanding how Git works then we will install Git, work on a local Git repository, work on a remote GitHub repository, and work on another developer's repository.

| **Goal** | Learn the basics you need to get started with Git and GitHub and apply them practically |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **What will you learn** | *Fundamentals of Version Control, Setting Up Git, Working with Local Repositories, Working with GitHub* |
| **What you'll need** | *[Git](https://git-scm.com/?wt.mc_id=studentamb_71460)*, *[GitHub](https://github.com/?wt.mc_id=studentamb_71460)* |
| **Duration** | *1h* |
| **Microsoft Cloud Topics taught** | *Git*, *GitHub* |
| **Slides** | *[Powerpoint](slides.pptx)* |

## Video

*coming soon*

## Pre-Learning

- Read this [introduction to Git](https://learn.microsoft.com/training/modules/intro-to-git/0-introduction/?wt.mc_id=studentamb_71460).
- Read this [introduction to GitHub](https://learn.microsoft.com/training/modules/introduction-to-github/1-introduction/?wt.mc_id=studentamb_71460).
- Read this [introduction to creating a Git project](https://learn.microsoft.com/training/modules/create-git-project/1-introduction/?wt.mc_id=studentamb_71460).
- Read this [introduction to collaborating with Git and GitHub](https://learn.microsoft.com/training/modules/collaborate-with-git/0-introduction/?wt.mc_id=studentamb_71460).

## Prerequisites

### Git

Git is the version control tool that we will be using throughout this workshop.
To install Git, follow these steps:
- Go to [git-scm.com/downloads](https://git-scm.com/download/?wt.mc_id=studentamb_71460).
- Download the suitable version of Git.
- Install it on your local machine.

### GitHub

GitHub is the cloud platform that we will use to share our code with others and collaborate on projects.
To set up a GitHub account, follow these steps:
- Go to [github.com/signup](https://github.com/signup/?wt.mc_id=studentamb_71460).
- Enter your email.
- Create a password.
- Enter a username. (Note that this is your unique identifier on GitHub.)

## The workshop

- [Part 0: Install and configure tools](./setup.md)
- [Part 1: Working with a Local Repository](./local-git.md)
- [Part 2: Working with Remotes](./remote-github.md)

## Feedback

Be sure to give [feedback about this workshop](https://forms.office.com/r/MdhJWMZthR)!

[Code of Conduct](../../CODE_OF_CONDUCT.md)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions full/intro-git-github-version-control/local-git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Part 1: Working with a Local Repository

Git tracks changes in your source code, enables versioning, and supports non-linear development through thousands of parallel branches without the need for the internet.

## Initializing a Local Git Repository

1. On your local machine, create a new empty folder.
2. Right-click inside the folder and select **Git Bash Here** from the options.

![Git Bash Here Screenhot](./images/git-bash-here.png)

3. Inside git bash, execute the following command to initialize a Git repository

```bash
git init
```

## Making Changes

1. Inside git bash, execute the following command to create a new file

```bash
touch new-text-file.txt
```

2. Inside git bash, execute the following command to open the newly created file

```bash
start new-text-file.txt
```

3. Add some text to the file then save and close it.

Common shell commands:
```bash
$ ls # used to list files and directories
$ mkdir # used to create a new directory
$ cd # used to change directories
$ rm # used to remove files and directories
$ pwd # used to print the current working directory
$ touch # used to create and modify files
$ start # used to open files or directories using the default program
```

## Staging Changes

In Git, just because a file was modified doesn't mean it will be automatically included in the next commit. Instead, you have to tell Git explicitly which of your modifications shall be part of the next commit. This is done by adding a change to the Staging Area or, put simply, by "staging" it.
Inside git bash, execute the following command to stage all the changes
```bash
git add .
```
> [!NOTE]
> The dot (.) here means all the changes.
>
> Instead of using it we can add the names of each changed file individually.
## Committing Changes
The "commit" command is used to save your changes to the local repository as it captures a snapshot of the project's currently staged changes. Committed snapshots can be thought of as "safe" versions of a project. Git will never change them unless you explicitly ask it to.

Inside git bash, execute the following command to commit all the changes

```bash
git commit -m "Imperative description of the changes"
```

> [!NOTE]
> Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug.". Try to avoid using dots at the end of your commit message.

## Reviewing the Repository's History

Git status displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git.

Inside git bash, execute the following command to see the status of your repository

```bash
git status
```

The output before making any changes:

```bash
On branch main
No commits yet
nothing to commit (create/copy files and use "git add" to track)
```

The output after what we have done:
```bash
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
new-text-file.txt
nothing added to commit but untracked files present (use "git add" to track)
```

The status output does not show you any information regarding the committed project history and that's why we need Git log as it will show us the history of our Git repository.
Inside git bash, execute the following command to get the history of your repository
```bash
git log
```
> [!NOTE]
> `git log` displays the following:
> - the SHA (unique ID for each commit)
> - the author (the email and username you configured Git with)
> - the date (the date of the commit)
> - the commit message (the message that you added with the commit)
>
> You can use `git log --oneline` to get a one-line version of the logs.
## Summary
Congratulations! You are now able to use Git on your local machine to manage your projects. Next you'll practice [working with remotes](./remote-github.md).
100 changes: 100 additions & 0 deletions full/intro-git-github-version-control/remote-github.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Part 2: Working with Remotes

While working locally may seem enough for some people sometimes we need to collaborate with others so, this is where a remote place to store our code comes into place, and our remote is GitHub a cloud platform used to share code with others and collaborate on projects.

## Creating a GitHub Repository

1. In the upper-right corner of any page, use the ➕ drop-down menu, and select **New repository**.

![Screenshot of a GitHub dropdown menu showing options to create new items. The menu item "New repository" is outlined in dark orange.](https://docs.github.com/assets/cb-31554/mw-1440/images/help/repository/repo-create.webp)

2. Type a short, memorable name for your repository. For example, "hello-world".

![Screenshot of the first step in creating a GitHub repository. The "Repository name" field contains the text "hello-world" and is outlined in dark orange.](https://docs.github.com/assets/cb-61138/mw-1440/images/help/repository/create-repository-name.webp)

3. Optionally, add a description of your repository. For example, "My first repository on GitHub."

4. Choose a repository visibility. For more information, see "[About repositories](https://docs.github.com/repositories/creating-and-managing-repositories/about-repositories#about-repository-visibility)".

5. Select Initialize this repository with a README.

6. Select Create repository.

## Cloning a Git Repository Locally

1. Above the list of files, select **<> Code**.

![Screenshot of the list of files on the landing page of a repository. The "Code" button is highlighted with a dark orange outline.](https://docs.github.com/assets/cb-32892/mw-1440/images/help/repository/code-button.webp)

2. Copy the HTTPS URL for the repository.

![Screenshot of the "Code" dropdown menu. To the right of the HTTPS URL for the repository, a copy icon is outlined in dark orange.](https://docs.github.com/assets/cb-45942/mw-1440/images/help/repository/https-url-clone-cli.webp)

3. Inside Git Bash, execute the following command replacing the URL with the URL you copied earlier

```bash
git clone https://github.com/YOUR-USERNAME/hello-world
```

This command:
- takes the path to an existing repository
- by default will create a directory with the same name as the repository
that's being cloned
- can be given a second argument that will be used as the name of the
directory
- will create the new repository inside of the current working directory
## Uploading Changes to GitHub
1. Inside Git Bash, execute the following command to change the directory to the newly cloned repository's directory

```bash
cd hello-world
```

2. Inside Git Bash, execute the following command to make some changes

```bash
echo "My first sentence on GitHub." > new-file.txt
```

3. Inside Git Bash, execute the following command to add the changes

```bash
git add .
```

4. Inside Git Bash, execute the following command to add the changes

```bash
git commit -m "Initial commit"
```

5. Inside Git Bash, execute the following command to push the changes to GitHub

```bash
git push
```


## Contributing on GitHub

1. Visit this repository [john0isaac/git-workshop-pr](https://github.com/john0isaac/git-workshop-pr/?wt.mc_id=studentamb_71460).
2. In the top-right corner of the page, click **Fork**.
3. Select **Create fork**.
4. Clone the repository locally.
5. Make changes to the repository by adding your name to the contribution list.
6. Add, Commit, and Push your changes.
7. Go back to the forked version of the repository on GitHub.
8. Select **Contribute** followed by **Open a pull request** to add your changes to the original repository.
9. Select **Create pull request**.
10. Enter a **Title** for your pull request. For example, YOUR-NAME contribution.
11. Select **Create pull request**.

## Summary

Congratulations! You have successfully created and cloned a GitHub repository. The repository you created can be shared with anyone which enables you to collaborate with others. You have also made your first contribution to another project. If you want to continue to grow your skills:

- Learn more about [GitHub on Microsoft Learn](https://learn.microsoft.com/training/github/?wt.mc_id=studentamb_71460).
- Finish [Introduction to version control with Git](https://learn.microsoft.com/training/paths/intro-to-vc-git/?wt.mc_id=studentamb_71460) learning path.
65 changes: 65 additions & 0 deletions full/intro-git-github-version-control/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Part 0: Install and Configure Git

As with any tool, we need to install and configure it before we can use it.

## Installing Git

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. If you don't already have Visual Studio Code installed, you can install it by doing the following:

On MacOS / Windows:
1. Go to [git-scm.com/downloads](https://git-scm.com/downloads/?wt.mc_id=studentamb_71460).
2. Download the software for Mac/Windows.
3. Install Git choosing all of the default options.

On Linux, execute the following command:
```bash
sudo apt-get install git
```

## Configuring Git

Open Git bash and execute the following Commands:

1. Configure your Git profile.

```bash
# sets up Git with your name
git config --global user.name "<Your-Full-Name>"
```

```bash
# sets up Git with your email
git config --global user.email "<your-email-address>"
```

2. Configure your UI output color.

```bash
# makes sure that Git output is colored
git config --global color.ui auto
```

3. Configure Git with your code editor:

i. For Atom editor, execute the following command:

```bash
git config --global core.editor "atom --wait"
```

ii. For VSCode, execute the following command:

```bash
git config --global core.editor "code --wait"
```

4. Review all the configuration options.

```bash
# lists all the configuration properties
git config --list
```

## Summary

Now, you have successfully installed and configured Git. The next step is to practice [working with a local repository](./local-git.md).
Binary file added full/intro-git-github-version-control/slides.pptx
Binary file not shown.
23 changes: 23 additions & 0 deletions full/intro-git-github-version-control/workshop-designer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Introduction to Git, GitHub, and Version Control

## Stage 1: Desired Results

1. Students will be skilled at using Git to manage their projects and collaborate with others on GitHub.
2. Students will be able to independently use their learning to apply version control concepts on their own projects.

## Stage 2: Evidence

As a result of the workshop, students will have Git installed and configured with GitHub on their local machine. They will also create a local Git repository and apply version control concepts to it. In addition to that, they will create a GitHub repository and clone it locally to make some changes and push it to GitHub again. In the end, they will fork a repo, apply the concepts they learned, and make a pull request.

## Stage 3: Learning Plan

Workshop milestones:
- Learn about Version Control.
- Install and configure Git.
- Create a Git local repository.
- Make changes, add, and commit them.
- Review the repository's history.
- Learn about remotes.
- Create a GitHub repository and clone it locally.
- Make changes and push to GitHub.
- Fork another developer's repository and make a pull request.

0 comments on commit 8547a4c

Please sign in to comment.