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
What is the purpose of the git commit command?
It records changes to one or more files in your branch and saves it as a reference point in the repository's history
26
What is the name of the starting branch when creating a new GitHub repository?
main
27
What are the steps to successfully create and merge a pull request?
1. Submit pull request with description 2. Make changes from feedback 3. Merge code
28
What does the code below indicate? <<<<<<<< HEAD - Intuitive and fun for use, offering the best in software >>>>>>>> feature
A merge conflict
29
Which command will list all branches of a Git project?
git branch
30
Why is the branch name 'my branch' invalid?
Branch names cannot contain whitespace
31
What does 'git branch -b new_branch' do?
Creates a new branch
32
What does the command below accomplish? git branch -d my-branch
It will delete 'my-branch'
33
A Git project has a branch 'bug-fix'. How do you switch to it?
git checkout bug-fix
34
Which is a common reason Git users make a new branch?
To develop a new project feature
35
Merging a branch into 'master':
Integrates changes made on the new branch into 'master'
36
When you are on 'master' and create a new branch:
The new branch and 'master' share the exact same commit history
37
You've merged a branch called 'new-feature' into 'master'. What is true?
'master' is the receiver branch
38
You try to merge two branches which contain commits that alter a file in conflicting ways. This is called:
A merge conflict
39
After cloning a remote repo, what is the next step in the Git collaborative workflow?
Fetch from the remote and merge into the local 'master' branch
40
What's true about the command below? git clone remote_location clone_name
The command clones a Git project
41
What piece is missing from the command below? git push origin
The name of the branch you wish to push up to the remote
42
What is a remote repo?
A Git repository that allows multiple collaborators to work on the same Git project
43
Which command merges the remote 'origin' into the local 'master' branch?
git merge origin/master
44
The output below is typical of which command? origin /home/ccuser/workspace/curriculum/science-quizzes (fetch) origin /home/ccuser/workspace/curriculum/science-quizzes (push)
git remote -v
45
The command 'git fetch' does what?
Fetches new commits from the remote, but does not merge them
46
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 working directory - A staging area - A repository
47
What is an example of a merge conflict?
Where FILE A has different changes on 2 separate branches, one of which is being merged into the other
48
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?
git merge room
49
What are the steps to resolve a merge conflict?
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
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?
git merge dinner
51
In Git, what command can you use after 'git reset HEAD filename' to see if the file was properly removed from staging?
git status
52
In the terminal, what Git command can be used to set HEAD to commit '3ba6efb'?
git reset 3ba6efb
53
When working in the terminal, what git command will remove all changes to 'text.js'
git checkout HEAD text.js
54
What git command can you use after 'git checkout HEAD index.js' to see if the rollback was successful?
git checkout
55
In Git, what is the current commit typically called?
HEAD
56
What git command can you use after 'git checkout HEAD index.js' to see if the rollback was successful?
git diff
57
What will unstage 'phone.js' from staging?
git reset HEAD phone.js
58
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'?
The first seven digits of the previous 'commit_SHA'
59