GitHub Flashcards
Where in Git do you typically create, edit, delete, and organise project files?
The working directory
What does the ‘git init’ do?
Initialise a new Git project
The output below is typical of which command?
commit bda95786432d142bbff996ad32045fa4f32ec619
Author: codeacademy
Date: on Nov 16 13:13:33 2015 -0500
First commit
git log
The command ‘git status’ shows:
Untracked files and file changes staged for commit
What is the purpose of Git’s staging area?
To show a list of your project’s commits
Why use Git?
To keep track of changes made to a project over time
In the code below, what will you replace ‘filename’ with?
git add filename
The file you wish to add to the staging area
What’s wrong with the code below?
git commit -m Add new scene to screenplay
The commit message lacks quotation marks
In Git, a commit:
Permanently stores changes from the staging area in the repo
What Git command gives the output below?
unstaged changes after reset:
M file.txt
git reset HEAD file.txt
Which Git command lets you view the SHAs of all previous commits?
git log
Why use Git backtracking commands?
- To discard changes in the working directory
- To go back to a previous commit
- To unstage a file from the staging area
Which statement is true about the command below?
git reset 844d1f7
HEAD will be reset to the commit whose SHA starts with 844d1f7
Why use the command below?
git checkout HEAD filename
To restore a file in the working directory to look as it did in the your last commit
Which command removes file changes from the staging area?
git reset HEAD filename
You accidentally deleted lines from a file. Which command can undo your mistake?
git checkout HEAD filename
In Git, the HEAD commit is:
The commit you are currently on
Complete the Git commands steps in order to push code changes from your local repository to the remote repository on GitHub
- git add .
- git commit -m ‘…’
- git push
Give three examples of best practice and an example of a bad practice when submitting a pull request?
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
When is the best time to delete a branch?
Once the pull request has been submitted and the code merged or if the code changes on the branch are no longer relevant
What are the major steps in the GitHub flow?
- Work on a specific branch
- Commit changes and push code to the remote repository
- Create a pull request
- Discuss pull request with reviewers
- Merge branch once pull request accepted
Give two examples of best practice and an example of a bad practice when reviewing a pull request?
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
What’s the general process of reviewing a pull request?
- Read the pull request description
- Comment on lines of code that need feedback
- Submit review
- Take a look again, repeat if needed