GitHub Flashcards

1
Q

Where in Git do you typically create, edit, delete, and organise project files?

A

The working directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the ‘git init’ do?

A

Initialise a new Git project

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The output below is typical of which command?
commit bda95786432d142bbff996ad32045fa4f32ec619
Author: codeacademy
Date: on Nov 16 13:13:33 2015 -0500
First commit

A

git log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The command ‘git status’ shows:

A

Untracked files and file changes staged for commit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of Git’s staging area?

A

To show a list of your project’s commits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why use Git?

A

To keep track of changes made to a project over time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In the code below, what will you replace ‘filename’ with?
git add filename

A

The file you wish to add to the staging area

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What’s wrong with the code below?
git commit -m Add new scene to screenplay

A

The commit message lacks quotation marks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In Git, a commit:

A

Permanently stores changes from the staging area in the repo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What Git command gives the output below?
unstaged changes after reset:
M file.txt

A

git reset HEAD file.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which Git command lets you view the SHAs of all previous commits?

A

git log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why use Git backtracking commands?

A
  • To discard changes in the working directory
  • To go back to a previous commit
  • To unstage a file from the staging area
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which statement is true about the command below?
git reset 844d1f7

A

HEAD will be reset to the commit whose SHA starts with 844d1f7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why use the command below?
git checkout HEAD filename

A

To restore a file in the working directory to look as it did in the your last commit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which command removes file changes from the staging area?

A

git reset HEAD filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

You accidentally deleted lines from a file. Which command can undo your mistake?

A

git checkout HEAD filename

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

In Git, the HEAD commit is:

A

The commit you are currently on

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Complete the Git commands steps in order to push code changes from your local repository to the remote repository on GitHub

A
  • git add .
  • git commit -m ‘…’
  • git push
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Give three examples of best practice and an example of a bad practice when submitting a pull request?

A

Best practice:
- Making pull requests smaller
- Submitting a pull request with a brief and succinct description of the changes made
- Adding images to the pull request

Bad practice:
- Submitting a pull request with untested code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

When is the best time to delete a branch?

A

Once the pull request has been submitted and the code merged or if the code changes on the branch are no longer relevant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are the major steps in the GitHub flow?

A
  1. Work on a specific branch
  2. Commit changes and push code to the remote repository
  3. Create a pull request
  4. Discuss pull request with reviewers
  5. Merge branch once pull request accepted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Give two examples of best practice and an example of a bad practice when reviewing a pull request?

A

Best practice:
- Express why certain code should be changed
- Providing objective and non-judgmental feedback

Bad practice:
- Only review the pull request description and glancing at the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What’s the general process of reviewing a pull request?

A
  1. Read the pull request description
  2. Comment on lines of code that need feedback
  3. Submit review
  4. Take a look again, repeat if needed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How would you define a Git branch?

A

A pointer to a set of code changes independent from other branches

25
Q

What is the purpose of the git commit command?

A

It records changes to one or more files in your branch and saves it as a reference point in the repository’s history

26
Q

What is the name of the starting branch when creating a new GitHub repository?

A

main

27
Q

What are the steps to successfully create and merge a pull request?

A
  1. Submit pull request with description
  2. Make changes from feedback
  3. Merge code
28
Q

What does the code below indicate?
«««&laquo_space;HEAD -
Intuitive and fun for use, offering the best in software
»»»» feature

A

A merge conflict

29
Q

Which command will list all branches of a Git project?

A

git branch

30
Q

Why is the branch name ‘my branch’ invalid?

A

Branch names cannot contain whitespace

31
Q

What does ‘git branch -b new_branch’ do?

A

Creates a new branch

32
Q

What does the command below accomplish?
git branch -d my-branch

A

It will delete ‘my-branch’

33
Q

A Git project has a branch ‘bug-fix’. How do you switch to it?

A

git checkout bug-fix

34
Q

Which is a common reason Git users make a new branch?

A

To develop a new project feature

35
Q

Merging a branch into ‘master’:

A

Integrates changes made on the new branch into ‘master’

36
Q

When you are on ‘master’ and create a new branch:

A

The new branch and ‘master’ share the exact same commit history

37
Q

You’ve merged a branch called ‘new-feature’ into ‘master’. What is true?

A

‘master’ is the receiver branch

38
Q

You try to merge two branches which contain commits that alter a file in conflicting ways. This is called:

A

A merge conflict

39
Q

After cloning a remote repo, what is the next step in the Git collaborative workflow?

A

Fetch from the remote and merge into the local ‘master’ branch

40
Q

What’s true about the command below?
git clone remote_location clone_name

A

The command clones a Git project

41
Q

What piece is missing from the command below?
git push origin

A

The name of the branch you wish to push up to the remote

42
Q

What is a remote repo?

A

A Git repository that allows multiple collaborators to work on the same Git project

43
Q

Which command merges the remote ‘origin’ into the local ‘master’ branch?

A

git merge origin/master

44
Q

The output below is typical of which command?
origin /home/ccuser/workspace/curriculum/science-quizzes (fetch)
origin /home/ccuser/workspace/curriculum/science-quizzes (push)

A

git remote -v

45
Q

The command ‘git fetch’ does what?

A

Fetches new commits from the remote, but does not merge them

46
Q

Complete each part of the Git project with its definition:

  • Where files are creating, edited, deleted, and organised
  • Where changes that are made to the working directory are listed
  • Where Git permanently stores changes as different versions of the project
A
  • A working directory
  • A staging area
  • A repository
47
Q

What is an example of a merge conflict?

A

Where FILE A has different changes on 2 separate branches, one of which is being merged into the other

48
Q

What command can you write in the terminal that will fuse the changes from the ‘room’ branch into the ‘house’ branch when you are in the ‘house’ branch?

A

git merge room

49
Q

What are the steps to resolve a merge conflict?

A
  1. Edit and save changes to any files with conflicts
  2. Add the files with conflicts
  3. Commit the changes to the files with conflicts
50
Q

In Git, you are currently in the ‘menu’ branch and you would like to merge the changes from the ‘dinner’ branch to your ‘menu’ branch. Which command will fulfil that?

A

git merge dinner

51
Q

In Git, what command can you use after ‘git reset HEAD filename’ to see if the file was properly removed from staging?

A

git status

52
Q

In the terminal, what Git command can be used to set HEAD to commit ‘3ba6efb’?

A

git reset 3ba6efb

53
Q

When working in the terminal, what git command will remove all changes to ‘text.js’

A

git checkout HEAD text.js

54
Q

What git command can you use after ‘git checkout HEAD index.js’ to see if the rollback was successful?

A

git checkout

55
Q

In Git, what is the current commit typically called?

A

HEAD

56
Q

What git command can you use after ‘git checkout HEAD index.js’ to see if the rollback was successful?

A

git diff

57
Q

What will unstage ‘phone.js’ from staging?

A

git reset HEAD phone.js

58
Q

In git, the ‘git reset commit_SHA’ command can be used to set ‘HEAD’ to the ‘commit_SHA’ commit.
What should the ‘commit_SHA’ contain if you wanted to reset it to the previous ‘commit_SHA’?

A

The first seven digits of the previous ‘commit_SHA’

59
Q
A