- Break out into groups of 5/6 ( depending on volunteer and trainee numbers )
- Use these instructions as a guide to check your understanding, resolve misconceptions and develop your understanding
This workshop starts with a recap based on this week's prep material...
- Trainees do this section in pairs
- ⏲️ 10 mins
Let's recap some of the things from earlier in the week.
Visit the following repository on GitHub: https://github.com/CodeYourFuture/cyf-demo-repo
Answer the following questions:
a) How many commits are there in the cyf-demo-repo project?
b) Who committed on Oct 31, 2020?
c) What changes did illictonion make in the commit titled "Revert changes accidentally pushed in the past"?
d) How many files were added in the first commit? What were the names of the files?
e) What is the hash for the first commit in the history?
f) What is Claire Bickley's favourite food?
- Group discussion
- ⏲️ 10 mins
- A volunteer will need to facilitate this section
A volunteer can facilitate this group discussion by going through the questions above and asking pairs for their feedback. If pairs are unsure / not quite accurate then spend a small amount of time addressing misconceptions. Remember to ask around for feedback.
- Trainees do this section in pairs
- ⏲️ 5 mins
Use the guidelines from the prep section of this week to create a fork.
- On one person's computer, fork this repo: https://github.com/CodeYourFuture/cyf-demo-repo
- 📝 Double-check the URL of your forked repo. How can you tell the fork was successfully created?
- Groups discussion
- ⏲️ 5 mins
- A volunteer will need to facilitate this section
A volunteer will need to navigate and let the group guide them in creating a fork as per the steps in the previous section.
- Trainees do this section in pairs
- ⏲️ 5 mins
Before continuing, try answering the following:
❓ what is the difference between a fork and a clone.
Remember to check your answer before continuing.
- Clone your fork of
cyf-demo-repo
to your local machine. - Open this local repository using VSCode.
- Use
pwd
in your terminal to check you're in the right place.
- Group discussion/demo
- ⏲️ 5 mins
- A volunteer will need to facilitate this section
A volunteer will need to navigate and let the group guide them in following through the steps in the previous recap activity.
- Trainees do this section in pairs
- ⏲️ 10 mins
Next, create a local branch called week-1-workshop
- Group discussion/demo
- ⏲️ 10 mins
- A volunteer will need to facilitate this section
- [ ] save local changes to a repository in VSCode
- [ ] stage local changes
- [ ] commit changes to a local branch
- [ ] define "pushing"
- [ ] push local changes on to remote repository
🎯 Goal: Make some local changes and create a local commit on our branch.
- Do this section in pairs
- ⏲️ 15 mins
Follow these instructions carefully.
Our Git timeline starts off with some commits like this:
We're going to figure out how to
- make local changes and commit them to our branch "week-1-workshop",
so our history looks something like this:
where the most recent commits contain our changes.
To create a commit, we can use the following steps (explained more below):
- Make a change to a file
- View the local changes
- Stage the changes
- Creating the commit
- Open up your local repo
cyf-demo-repo
in VSCode. - Go to the Explorer section of VSCode ( look for a 🔍 icon ).
- Find
file.txt
and edit the file with the answer to the questions. - Remember to save the changes to
file.txt
.
Tip:
- You can use Cmd + S on a Mac to save changes to a file in VSCode.
- You can use Ctrl + S on a Linux OS to save changes to a file in VSCode.
We want to view the changes we've just made to our working directory.
- Locate the Source Control tab in VSCode.
- Go to the Changes section and click on the file you changed - this should now show the changes for the file.
- Try editing the file again in the Explorer tab and check to see the update is visible in the Source Control panel
We need to tell Git which changes we want to be part of our next commit.
Each commit is a checkpoint we've decided to save. When making a commit, we can decide to not include all of our changes in the checkpoint, but just include some of them.
We choose which changes we want to include in a commit by staging our changes.
In the Source Control tab again...
- Go to the file
file.txt
and click on the +.
👓 Notice what happens when you carry out step 1.
- View the Staged Changes area in your Source Control panel.
Once we've staged our changes, then we can commit these changes.
Before we do, we should make sure we're on the correct branch. Check that you're on the week-1-workshop
branch.
Your VSCode window should look like this:
and not like this:
If you're sure you're on the right branch:
- Enter a commit message describing briefly what you did in your commit.
- Click Commit to create the Git commit.
📝 Now figure out how many commits you have on your local machine.
🧠 Explain what you think would have happened if you didn't stage anything in your working directory when you made your commit.
❗ Once you've completed this commit, swap roles in your pair. Choose another file and then go through the steps in the Creating a commit section
- Group discussion/demo
- ⏲️ 10 mins
- A volunteer will need to facilitate this section
A volunteer will now need to navigate with directions from the group. Go through the git commit steps together. Also use this time for clarifying questions.
🎯 Goal: Push a branch to a remote repository
- Trainees work in pairs
- ⏲️ 5 mins
After committing your work on your machine, you'll have a local branch that looks like this
---
title: cyf-demo-repo
---
gitGraph
commit
commit
branch "week-1-workshop"
commit
commit
📋 Double-check you've been committing to your branch week-1-workshop
branch and not your main
branch.
However, our remote fork only has a main branch:
---
title: cyf-demo-repo
---
gitGraph
commit
commit
In other words, we have not added our local branch onto the remote fork on GitHub.
To do this, we must push our branch onto GitHub.
push means adding local work to a remote GitHub repository.
🔍 Figure out how to push your local branch to the GitHub repository using the Source Control interface in VSCode.
🔍 Figure out how to check the week-1-workshop
branch is on the remote fork.
- Group discussion/demo
- ⏲️ 5 mins
- A volunteer will need to facilitate this section
A volunteer will need to navigate and let the group guide them in following through the steps in the previous recap activity.
Now is some time to wrap up and try and discuss some of the key concepts from this week.
- Trainees discuss in pairs
- ⏲️ 10 mins
In your pair, discuss the following questions/tasks:
- what is a commit? explain why need to make commits when we're developing a project?
- explain why we store repositories on GitHub
- describe the purpose of VSCode
- explain the difference between Git and GitHub
- explain why developers use branches
- explain the difference between a fork and a clone?
- what does the branch name
origin/main
mean instead of justmain
- Check out the following git repository diagram below:
How many commits are in common between week-1-feature
and main
?
---
title: cyf-demo-repo
---
gitGraph
commit
commit
commit
branch "week-1-feature"
commit
commit
- Discuss the questions together as a group. Go round and get feedback from each person in the group.