Git and Github - Week 1
Learning Objectives
- You will be able to create a repository on Github
- You will be able to clone a repository using Github Desktop
- You will be able to make changes to a repository using Github Desktop
- You can define what the differences between Git and Github are
- You can use git to submit all your homeworks to Github
What is the problem?
When programmers work together it can be hard to stay in sync. This can be demonstrated by:
- Have one person write three words on a piece of paper
- Give the paper to the teacher and the teacher makes a copy of it
- Somebody else can request the paper from the teacher
- Change a word on the paper and give it back to the teacher.
The teacher is the single source of truth for the project. This is fine so long as both people don't make a change at the same time.
- Now both students change a word on their piece of paper
- They then try to give both pieces of paper to the teacher
- But the teacher doesn't know what to do! Which one is correct?
This is why Git was invented!
What is Github?
Confirm that everyone has a Github account and that they've been added to the relevant Github Teams
- Give an overview of Github including
- A Project Overview
- Issues
- Creating a repository
- Changing a file in a repository
- All students should now
- Create a repository called "Code Your Future". This should include the ReadMe.md.
- Edit the ReadMe.md inside Github to include their name.
What is Github Desktop?
Github desktop is a way to edit files on your computer instead of editing them online.
Give a demonstration of
- Cloning a repository
- Making a change to a file in the repository
- Committing the changes to our local repository
- Pushing our changes to Github
The students should now repeat these steps on their projects
What about working in Teams?
Github also makes it really easy to work in teams.
One way that we could work in a team is by writing a story together.
In your teams you should.
- Elect a Project Leader
- The Project leader should create a repository on Github and then share the link to the team
- All of the rest of the team should clone the repository
- Each team member should take it in turns changing one work in the ReadMe.md file in the project.
- Write a story! Keep on adding works until you've got a story.
Be careful! Don't all add words at the same time!
Branching
Sometimes it can be useful to work on something for a long time before showing it to everyone. This is why we use branching.
The teacher should
- Show how you can create a branch in Github Desktop
- Show how moving between Master and the Branch keeps two versions of the file
Branching is particularly helpful for using in Pull Requests
- The teacher should show how to make a Pull Request in Github
- The teacher should show how to comment on a PR in Github
- The teacher should show how to merge a pull request in Github
Now the students should try this themselves in their teams.
- The group leader should make a Branch, make a Commit and Create a Pull Request
- The other students should comment on the Pull Request
- The group leader should then merge the Pull Request
Now each member of the team should try this!
(Optional) What is Git?
This is advanced!
The Github Desktop tool is actually built on top of something called Git. Git lives entirely in the command line.
The teacher should show
- How to clone a repository
- How to make a commit
- How to how to push to the repository
This is only to show students how it's done! We'll be doing more of this in the future.