Class 8C. Version Control with Git#

../../../_images/git.jpeg

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?#

http://www.phdcomics.com/comics/archive/phd101212s.gif

What is Git?#

https://www.nobledesktop.com/image/blog/git-branches-merge.png

Image Source: Noble Desktop.

Revisiting Learn Git Branching#

../../../_images/learn_git_branching.png

The GitHub Flow#

Hide 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#

  1. Message your group mates and get in touch with them

  2. ONE PERSON IN EACH ROOM, will fork this repository onto your own GitHub account

  3. Clone that fork onto your computer

  4. Add your teammates to the repository

  5. Teammates clone onto computer

  6. 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