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
How would you define a Git branch?
A pointer to a set of code changes independent from other branches
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
What is the name of the starting branch when creating a new GitHub repository?
main
What are the steps to successfully create and merge a pull request?
- Submit pull request with description
- Make changes from feedback
- Merge code
What does the code below indicate?
««««_space;HEAD -
Intuitive and fun for use, offering the best in software
»»»» feature
A merge conflict
Which command will list all branches of a Git project?
git branch
Why is the branch name ‘my branch’ invalid?
Branch names cannot contain whitespace
What does ‘git branch -b new_branch’ do?
Creates a new branch
What does the command below accomplish?
git branch -d my-branch
It will delete ‘my-branch’
A Git project has a branch ‘bug-fix’. How do you switch to it?
git checkout bug-fix
Which is a common reason Git users make a new branch?
To develop a new project feature
Merging a branch into ‘master’:
Integrates changes made on the new branch into ‘master’
When you are on ‘master’ and create a new branch:
The new branch and ‘master’ share the exact same commit history
You’ve merged a branch called ‘new-feature’ into ‘master’. What is true?
‘master’ is the receiver branch
You try to merge two branches which contain commits that alter a file in conflicting ways. This is called:
A merge conflict
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
What’s true about the command below?
git clone remote_location clone_name
The command clones a Git project
What piece is missing from the command below?
git push origin
The name of the branch you wish to push up to the remote
What is a remote repo?
A Git repository that allows multiple collaborators to work on the same Git project
Which command merges the remote ‘origin’ into the local ‘master’ branch?
git merge origin/master
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
The command ‘git fetch’ does what?
Fetches new commits from the remote, but does not merge them
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
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
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
What are the steps to resolve a merge conflict?
- Edit and save changes to any files with conflicts
- Add the files with conflicts
- Commit the changes to the files with conflicts
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
In Git, what command can you use after ‘git reset HEAD filename’ to see if the file was properly removed from staging?
git status
In the terminal, what Git command can be used to set HEAD to commit ‘3ba6efb’?
git reset 3ba6efb
When working in the terminal, what git command will remove all changes to ‘text.js’
git checkout HEAD text.js
What git command can you use after ‘git checkout HEAD index.js’ to see if the rollback was successful?
git checkout
In Git, what is the current commit typically called?
HEAD
What git command can you use after ‘git checkout HEAD index.js’ to see if the rollback was successful?
git diff
What will unstage ‘phone.js’ from staging?
git reset HEAD phone.js
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’