Class 8C. Version Control with Git#
Lecture Outline#
1. Announcements (2 mins)
2.Version Control with git? (3 mins)
3. The GitHub flow (5 mins)
4. Introduction to Branches and Pull Requests (10 mins)
5. Guided Activity: Create a Branch, submit a Pull Request (25 mins)
Request for Volunteers !#
You don’t need to have any prior experience, nor do you have to be a computer pro.
Probably will just ask you to share your screen and follow directions.
I’ll walk you through what you have to type and click and hopefully it’s illustrative what needs to be done.
You don’t need to be a computer or git expert!
2. Version Control with Git#
Why Git?#
What is Git?#
Image Source: Noble Desktop.
Revisiting Learn Git Branching#
The GitHub Flow#
Show code cell source
IFrame(
"https://enterprise.github.com/downloads/en/github-flow-cheatsheet.pdf",
width=1200,
height=800,
)
GitHub Guides#
See this link for lots more about using GitHub: git-guides
Guided Activity: Create and resolve a merge conflict#
Message your group mates and get in touch with them
ONE PERSON IN EACH ROOM, will fork this repository onto your own GitHub account
Clone that fork onto your computer
Add your teammates to the repository
Teammates clone onto computer
Try to create and resolve a merge conflict.
Lecture Outline#
1. Announcements and Recap (5 mins)
Part 1. Announcements (5 mins)#
Part 2. Introduction to Branches and Pull Requests (20 mins)#
Create and switch to a new branch#
To checkout a new branch that doesn’t already exist, use:
git switch -c new_branch_name
Switch to an existing branch#
To switch to a new branch that already exists, use:
git switch branch_name
Part 3. Guided Activity: Create a Branch, submit a Pull Request (20 mins)#
- Important! Use your Group Project repo
Partner 1: “Contributor 1”
Partner 2: “Contributor 2”
Partner 3: Contributor 3”
Partner 1 Creates and switches to a new branch:
git switch -c newchange1
Partner 2 Creates and switches to a new branch:
git switch -c newchange2
Partner 3 Creates and switches to a new branch:
git switch -c newchange3
All partners make sure the branch is switched:
git status
Partner 2 creates a new md file:
code newfile.md
Write a bunch of stuff
Save
git add .
git commit -m “new change”
git push
Partner 2 goes to the Github.com repo,
Click “Compare and Pull Request”
Request a review from Partner 1 and Partner 3
Submit Pull Request
Partner 3 does the same thing as above
Tips#
Here are some command sequences that might be useful:
- git switch -c 'person1'
- git switch -c 'person2'
- edit the file
- add, commit, push
- deal with the Pull Request(PR) on GitHub