Sharing code with git push, pull and clone

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Sharing code with git push, pull and clone

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which command copies a remote repository onto your computer for the first time?
A git clone
B git push
2. You have made two commits on your laptop. Which command uploads them to the remote repository?
A git pull
B git push
3. A teammate pushed new code to the remote. Which command brings it into your copy?
A git pull
B git push
4. True or false: git push uploads uncommitted changes in your working folder.
A False: git push only uploads commits
B True: git push uploads every saved file
5. Which line correctly copies a project from a web address?
A git pull https://github.com/team/app.git app
B git clone https://github.com/team/app.git

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1git clone https://github.com/sam/quiz.git AUploads your new commits from your computer to the main branch on the remote
2git push origin main BCopies the whole remote repository, with its history, onto your computer
3Download your teammates' latest commits and add them to your local copy Cpush uploads your commits, it does not download. To receive a teammate's work you need git pull.
4Make a first copy of a shared project on your own computer Dgit clone https://github.com/sam/quiz.git
5git push origin main (to get a teammate's new work) Egit clone needs the URL of the remote repository, not the remote name and branch name.
6git clone origin main (to copy a project) Fgit pull origin main

Definitions

git clone, git push, git pull

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
git _____ https://github.com/sam/quiz.git
2.
git ____ origin main
3.
git ____ origin main
4.
git commit -m "Fix score bug" git ____ origin main git push origin main
5.
git push ______ main

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A cd app
B # get teammates' new commits
C git push origin main
Question 2
A git copy https://g.co/app.git
B cd app
C git log --oneline
Question 3
A git commit -m "Add login"
B # upload my commit to remote
C git pull origin main
Question 4
A # share my commit with team
B git push main origin
C git log --oneline
Question 5
A git clone https://g.co/app.git
B cd app
C git commit -am "Fix typo"
D git psuh origin main

Answer Key

Sharing code with git push, pull and clone
Section A: Quick Questions
Q1
A — git clone
Q2
B — git push
Q3
A — git pull
Q4
A — False: git push only uploads commits
Q5
B — git clone https://github.com/team/app.git
Section B: Match the Pairs
Q1
git clone https://github.com/sam/quiz.git → Copies the whole remote repository, with its history, onto your computer
Q2
git push origin main → Uploads your new commits from your computer to the main branch on the remote
Q3
Download your teammates' latest commits and add them to your local copy → git pull origin main
Q4
Make a first copy of a shared project on your own computer → git clone https://github.com/sam/quiz.git
Q5
git push origin main (to get a teammate's new work) → push uploads your commits, it does not download. To receive a teammate's work you need git pull.
Q6
git clone origin main (to copy a project) → git clone needs the URL of the remote repository, not the remote name and branch name.
Section C: Definitions
Q1
git clone, git push, git pull — clone copies a remote repository to your computer; push uploads your commits to the remote; pull downloads other people's new changes into your copy.
Section D: Fill in the Blanks
Q1
git clone https://github.com/sam/quiz.git
Q2
git push origin main
Q3
git pull origin main
Q4
git commit -m "Fix score bug" git pull origin main git push origin main
Q5
git push origin main
Section E: Spot the Error
Q1
C — git push uploads your commits. To download teammates' new commits you need git pull origin main.
Q2
A — There is no git copy command. To copy a remote repository to your computer, use git clone followed by the URL.
Q3
C — git pull downloads changes from the remote. To upload your commit to the remote, use git push origin main.
Q4
B — The remote name comes before the branch name. It should be git push origin main.
Q5
D — The command is misspelt. It should be git push origin main to upload the commit to the remote.