Lecture

Git time

Create git hub account

  • Open github.com
  • Sign up: username, email, password
  • Choose free option
  • Verify email - click link in email
  • Done

Create git project

  • Open github.com and login if needed
  • Select 'repositories' and create new one
  • Name it redi_js_spring_2020
  • Make it public
  • Done

Invite collaborators

  • Open github.com
  • Select your project, open settings
  • Select: Manage access
  • Add all teachers as collaborators:
    • aberezhk, BTBTravis, caritosteph, jeffersondarcy, MrTim
  • Done

Download and install git

  • Check if you have 64 or 32 bit system
  • Open Downloads and select your OS
  • Download git executable (64 or 32 bit)
  • Execute it
  • Accept all default settings
  • Done

Clone your project

  • Open This PC -> C: -> create folder 'projects' and open it
  • Right mouse click -> open git bash here
  • Open your project in git hub
  • Select HTTPS and copy the link
  • Select opened git bash window
    • type git clone and paste repo link in the same line
    • git clone https://github.com/.../redi_js_spring_2020.git
  • Enter your github password if asked

Create README.md file

  • Open folder with your project: C:/projects/redi_js_spring_2020
  • Create file README.md
  • Open readme file and add some text
    • Project created by ... for Redi JS class
  • Save the file

Stage (add) README.md file

  • Open git bash in your project folder: C:/projects/redi_js_spring_2020
  • Execute git status
    • README.md is red
  • Execute git add README.md
  • Execute git status
    • README.md is green

Commit README.md file

  • In git bash in your project folder: C:/projects/redi_js_spring_2020
  • Execute git status
    • README.md is green
  • Execute git commit -m 'my commit message'
  • Execute git status
    • README.md is not shown

Push README.md file to github

  • In git bash in your project folder: C:/projects/redi_js_spring_2020
  • Execute git push
  • Enter your github password if asked
  • Open your project in github
  • README.md file shall appear in your repository
  • Great success!!

Create new branch

  • In git bash in your project folder: C:/projects/redi_js_spring_2020
  • Execute git branch -a
    • all existing branches are displayed
    • only master branch exists for now
  • Execute git branch my-first-branch
  • Execute git branch -a
    • master and my-first-branch are displayed

Switch to a newly created branch

  • In git bash in your project folder: C:/projects/redi_js_spring_2020
  • Execute git checkout my-first-branch
    • you are now on my-first-branch branch
  • Execute git checkout master
    • you are now on master branch

Challenge 🤪

  • Create index.html and push it to my-first-branch
    • switch to my-first-branch branch git checkout ...
    • create index.html file with some content
    • check for changes git status
    • stage changes for commit git add ...
    • commit changes git commit ...
    • push changes to github git push
  • Check your changes appear in github

Create a pull request to merge branch to a master

  • Open your repository in github
  • Select 'branches'
    • master and my-first-branch displayed
  • Click 'New pull request' for my-first-branch
    • Write some comment
    • Select all teachers as reviewers
    • Assign pull request to yourself
  • Create pull request

Merge branch to master

  • In your repository in github select Pull Requests
  • Select and open existing pull request
  • Click 'Merge pull request and 'Confirm merge'
  • Check that index.html appears on master branch in github
  • Celebrate! 🎉 🍻

Homework work

Instructions here