What is version control?
What is Git?
File states
Tracked (Unmodified, Modified, Staged), Untracked
Restoring files
git restore .
git checkout .
Ignore files
why? sensitive info, personal notes, system file
Using .gitignore


Git log -p
By adding the option -p, all changes are shown in the history.
What key closes the commit log view?
When you press Q, you will get to the prompt. The alternative is to keep pressing space, but that could take a long time!
What happens when you delete a file from a Git repository and commit your changes?
It is deleted from the current code, but still visible in the history.
While the code is no longer visible in the current files, it is saved in the history.
git log --grep='example'
To find all the commits with the phrase ‘example’ in them
git restore .
This will remove all changes you have made.
Git status tells you “Your branch is ahead of ‘origin/main’ by 1 commit. What does this mean?
You have committed changes that are not in the remote repository. You can fix this situation by using Git Push.
You have staged some changes in the file example.txt, but you decide you don’t want to commit them. Which command do you use?
git restore --staged example.txt
What is the most likely cause if ‘git status'
results in the output “Not a Git repository”?
There is no .git directory in the current directory or in parent directories. Git will check parent directories to confirm the user is not in a subdirectory of a repository.
git diff --staged
view the changes in the staging area
You have four commits in your project, and the HEAD is the most recent. What do the Git logs show after reverting the third commit?
The logs show a fifth new commit indicating which commit was reverted.
History will not be rewritten in Git; the log will show that a commit was reverted.
How do you go back to a specific commit?
git checkout
. You use git checkout to look back at a specific commit.
Which command do you use to view the changes in the files you are going to commit?
git diff
. Git diff will show you the lines in the code that have been changed.
In what way does the commit history change when git revert
is executed?
HEAD points to a new revert commit that is a descendent of the previous HEAD.
Because Git prioritizes integrity of data, the ancestry of HEAD will not change — a new commit that reverts the prior commit’s changes is added.
What does a detached state mean?
The files you see are not connected to the current version of your code.
You are in some part of the history of your git repository, so you cannot commit anything in the current branch.
You have a file in the staging area. What changes will Git Status make to your repository?
Nothing. Git Status shows what your current state is, it will not change that state.
What file do you need to add to make Git ignore certain files?
.gitignore
When you add a gitignore file, all files mentioned in there will no longer be tracked.
Which line in a .gitignore file would ignore all files ending in “.md” in a directory named logfiles, and nothing else?
logfiles/*.md
You make some changes to your repository and push them to the remote repo. You get an error: “failed to push some refs to [url]”. What went wrong?
You first need to run git pull. This error means there is a difference between the remote repository and the local repository. When you run git pull, it will collect the changes from the remote repository.
How many branches does a repository need to work?
Every repository has 1 branch, as the main branch is also a branch!
Why do you create a pull request?
to get the code from a branch added to the main branch. A pull request is used to get code to a main branch and enable automatic testing and reviews.
Which command helps to create a multiline git commit message?
git commit -m “First line of the commit message” -m “Second line of the commit message”
To get information about a remote repository, but not change any branches you can issue this command.
git fetch
The feature that allows you to create a website out of files in your directory is called _____
.
- github pages
Which one of these commands is only used when managing remote repositories?
git pull
Which feature of git allows you to save checkpoints in time that you can come back to?
commits
When dealing with merge conflicts, what command do you use to move between branches?
git switch
What option can you add to the git log statement to display an entry per line?
oneline
What command can you use to add an item to a previous commit?
amend
What’s the command you can use to delete a file?
git rm
Which command will let you get an item from the stash without removing it?
git stash apply
What’s the terminal command that lets you configure different options for git?
git config
Which environment is the temporary placeholder for files before you create a new point in the timeline you can go back to?
staging
Leave a Reply