1 of 44

Intro to Git @ Learn Day

2 of 44

Who am I?

Victoria Lim

2nd year, Cognitive Systems

cmd-f logistics coordinator

3 of 44

Who are we? Meet the TAs!

JP Garcia

4th Year, CMS

nwPlus Treasurer

Christy Lo

4th Year, BUCS

cmd-f Logistics Coordinator

Lucy Hao

3rd Year, CS

Marketing Coordinator

4 of 44

Who are we? Meet the TAs!

Stephanie Chen

4th Year, CS

cmd-f Logistics Director

ShuTing Hu

4th Year, CS

Co-President

5 of 44

  • Seek out a TA!
    • File a TA ticket
  • Ask away on Discord under the #intro-to-git channel!
  • Refer to the code snippets:
  • Refer to shortcuts:
    • (last slide)

Reminders- what to do if you get stuck!

6 of 44

Before you get started, make sure you:

7 of 44

What to expect:

  • What is Git?
  • How is Git used?
  • What is Git? (Part 2)
  • Using Git & GitHub
  • The intermediate stuff: Branches + pull requests

Special thanks to Joice Tang (nwAlum) and Kristen Kwong for letting us adapt their amazing slides/content <3

8 of 44

What is Git?

9 of 44

Version Control: The Basics

  • Keeps track of a history of changes to software code
  • Allows for collaborative development
  • Lets us go back and revert to older versions of our work

10 of 44

So, Git is...

  • A type of version control
  • A distributed version control system, which means you can work offline!
    • (A centralized version control system needs to be online)

11 of 44

What’s the difference?

  • Git = version control; keeps track of source code + history
  • GitHub = cloud-based hosting service; helps you manage Git repositories

12 of 44

Last definition for now...what’s a repository?

  • Where Git stores the metadata and object database for the project
    • Aka all the files related to your code!
  • Each developer has a copy of the code in a local repo on their computer and (most likely) a remote repo on a server
    • Local repo: make changes to your own copy of the code

13 of 44

How is Git Used?

14 of 44

How do you collaborate?

(w/o Git)

15 of 44

16 of 44

More about Git...

17 of 44

The 3 Stages of A Git File:

  • Modified: changed but not stored in repo yet - READY
  • Staged: marked that this goes into the next commit to be stored into repo - GET SET
  • Committed: stored into repo - GO
    • Sort of like a snapshot: when you commit, Git saves a “picture” of what your files look like
    • Each commit represents the changes made to your project in the past, along with details about when it was modified + who made the changes, along with an included message.

18 of 44

Let’s use Git!

19 of 44

Step 1: Install

20 of 44

Step 2: Configure

  • Making sure your contributions can be identified (+ give you those beautiful commit squares on your GitHub profile!)

21 of 44

Let’s create our repo!

22 of 44

Step 4: Create and Clone

  • Create:
    • Name the repo after your username
    • Add a README file
    • Open up the dropdown + copy the repo link
  • Clone:
    • Creates a folder that you can work on locally (offline)

23 of 44

Step 5: Edit!

  • Navigate to the folder for the repo on your computer and open up the README.md file with Visual Studio Code
  • I’ll give you all ~ 8 minutes to write what you’d like to share with the world!
  • Please react in Discord to let me know if the workshop speed has been okay for you so far!
  • When you’re done, save your file (ctrl-s/cmd-s)
    • in terms of Git stages, your file is now modified!!!

24 of 44

Step 6: See + stage changes!

  • View differences between your working directory and your git local repo

  • This adds all the files in your folder to staging
  • The code snippets doc has other adding options (single file, multiple specific files) in the toggle if you’re interested!

25 of 44

Step 7: Let’s commit!

  • Makes a new commit to the local repo with the given commit message

26 of 44

Step 8: Let’s push!

  • Pushes your changes up to the remote repository
  • It’s possible for you to wait and push several commits at once, if that’s more your style

27 of 44

Step 9: Let’s review!

  • Shows all the commits you’ve made up to this point (... on this branch)

28 of 44

Branches...

29 of 44

What are branches?

  • Branching is when you diverge from the main line of development and work directly on your own independent line

https://www.atlassian.com/git/tutorials/using-branches

30 of 44

31 of 44

Pros...

  • Really helpful if you’re focusing on specific pieces of the project and collaborating with others!
    • Makes sure you don’t have to do too much work to get old code back (because you’re isolating your work from others!)
      • Changes in other branches will not affect your work unless you pull them.
    • Helps you to solve any conflicts between you and your collaborators’ code + make the best choices for the project!

Source for image on next slide: https://backlog.com/git-tutorial/using-branches/

32 of 44

Step 10: Let’s make some!

  • You can use the below command to make a new branch
  • If you want to make a new branch and go directly to it, you can use the command in the toggle in the code snippet doc

33 of 44

Step 11: Some cool things you can do...

  • List all branches:

  • Go to a specific branch:

34 of 44

Step 12: Add some stuff!

  • I’ll give you 5 minutes to make a change to your README file
  • If you can’t think of anything, just add a punctuation mark somewhere

35 of 44

Step 13: Stage + commit your changes!

  • Fun trick that can make things easier – you can actually do both at once!

36 of 44

Step 14: Push it!

  • Our branch has only been created on our local machines, so we’ll need to use a special command to push our branch up to the remote repo

37 of 44

Step 15: Merge branches!

  • We want to checkout the branch we want the new code to go into (master/main, in our case)
  • Once you’re in the branch, merge the new code in!

38 of 44

Pull requests?

39 of 44

Pull requests...

  • You might want others to review your code before you push to master
  • Why?
    • You might not want to share code that’s incomplete
    • It’s also not that great to push to master – it might break other people’s code
  • After pushing your new branch to the remote repo, you can create a pull request to merge it with master

40 of 44

Step 17: Let’s pull it!

  • Compare + pull request
  • Create pull request
  • Merge pull request

41 of 44

FINALE...

  • Make sure you get these remote updates on your local machine
  • Pulling is super important if you’re working with other people, because they’ll be updating it too!

42 of 44

43 of 44

  • If you haven’t joined our discord server yet, please do so: https://discord.gg/hackcamp2021
  • Collect your stamps in #intro-to-git channel (react to the message)
  • Take a break + prepare for more fun workshops later!
  • Follow us on social media @nwPlus
  • THANKS FOR COMING <3

Before you go...

44 of 44

Shortcuts

  • Ctrl +k +u -> uncomment code!
  • q -> to get back to where you were