Git & Github 101
Outcomes
Part 1: Theory (25 minutes)
1. How to use the terminal with Git
2. What is Git and Github?
3. How does Git work and how to use it?
4. How to use GitHub: the basics
Part 2: Challenges (1.5 hours)
1. Collaborate on an open source project
INTRO TIME 🎉
1. Your lovely name
2. Why you want to learn git and GitHub
3. One passion of yours
Let’s make it easy
What’s the difference?
Tool Service
Version control tool used to track changes Hosting service for Git repositories
Installed locally Hosted on the cloud
Command line (terminal) The web
Using the terminal
to navigate your computer
Terminal Commands Basics
$ pwd
$ ls
$ cd ~/desktop
$ mkdir folder_name
$ cd folder_name
$ touch file_name
- print working directory
- list directory contents
- *change directory to desktop*
- *change directory*
- make directory
- create file
Important Terminal Commands
(for today)
$ cd ~/desktop
$ cd folder_name
*change directory to desktop*
*change directory*
Tracking changes
with git
Git Commands: Commit
$ git init
$ git status
$ git add file_name
$ git diff
$ git commit -m “message”
- initialise git in current folder
- show modified files
- add file
- show changes made
- commit your files with a message
Saving your files locally
working
directory
staging local
repository
git add git commit
Pushing to GitHub
working
directory
staging local
repository
git add
remote
repository
git commit git push
Setting up a
GitHub remote
https://github.com/
Git Remote Commands
$ git remote add origin (HTTPS)
$ git remote -v
$ git push origin <branch_name>
$ git pull origin <branch_name>
+
- add remote
- check remote URL
- push branch
- pull and integrate branch
Pushing to GitHub
working
directory
staging local
repository
git add
remote
repository
git commit git push
git pull
Branches
master
master branch
new branch
$ git branch branch_name
$ git checkout branch_name
$ git diff master branch_name
$ git merge branch_name
$ git branch -D branch_name
Git Local Commands: Branch
- check branches
- change branch
- show diff between branches
- merge branch into another
- delete unused branch
Collaborating on an
open source project
Git Remote Commands
$ git clone link (HTTPS)
+
- copy the target repository
Submitting a
pull request
Challenges 💪
The following slides are challenges to solve
with your workshop buddy (pair programming).
Challenges
Use git along with GitHub to
collaborate on an open source project.
Commands Cheatsheet
bit.ly/git101cheatsheet
+
GitHub Repository Setup
Click on this link or type it in your browser for access
bit.ly/git101workshop
+
Challenge 1
1. Using the terminal make sure your working directory is set to desktop.
2. Make a clone of the git-101-women-who-code repository.
3. Jump into that repository.
Cloning a project from Github automatically initialises git.
+
Challenge 2
1. Create a new branch and checkout into it.
2. Update the HTML file with your name and a star beside it. Save it.
3. Using git commands add the updated HTML file.
4. Then, commit the changes on that branch with a unique message.
5. Finally, push your branch to GitHub.
Discuss: How do you list the remote repositories linked to your project?
+
Final Challenge 🎉
1. Open a Pull Request on GitHub for me to review.
2. If your Pull Request got accepted, your changes are added to the
codebase and available here:
bit.ly/gitchampion
+
Give your partner a high-five ✋
Congratulations!
You’ve completed Git 101 with flying colours!
Twitter: @lewagonMEL
joy.seng@lewagon.org
Twitter: @WWCodeMelbourne
princy@womenwhocode.com

Git 101 Workshop