Q2. What command lets you create a connection between a local and remote repository?
Q3. Describe what the following git commands do to the commit history.
git reset --hard HEAD~5
git merge --squash HEAD@{1}
Explanation
git reset --hard HEAD~5
(Reset the current branch to the commit just before the last 5)
git merge --squash HEAD@{1}
(HEAD@{1} is where the branch was just before the previous command. This command sets the state of the index to be as it would just after a merge from that commit)
Q4. Your current project has several branches; master, beta, and push-notifications. You've just finished the notification feature in the push-notification branch, and you want to commit it to beta branch. How can you accomplish this?
Q5. Which of the following is true you when you use the following command?
git add -A
Q6. What will the following command print to the Terminal?
git remote -v
Q7. Looking at the following commands, describe what is happening.
git checkout feature-user-location
git cherry-pick {kj2342134sdf090093f0sdgasdf99sdfo992mmmf9921231}
Q8. What does the following command do to the git repository?
git reset --soft HEAD^
Q10. Why would the following command be used?
git rebase -i HEAD~10
build/
*.txt
*.metadata
Explanation
A line starting with #
serves as a comment. Hence # .swift
does not do anything.
Q17. After you make changes to a tracked file, you run the following command. What will this do?
git commit -a -m "Refactor code base"
Change to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: beta-notes.js
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout --<file>..." to discard changes in working directory)
modified: beta-notes.js
Q20. What commands would you use to force an overwrite of your local files with the master branch?
git pull --all
git reset --hard origin/master
git pull -u origin master
git reset --hard master
git pull origin master
git reset --hard origin/myCurrentBranch
git fetch --all
git reset --hard origin/master
Q21. Which statement is true when you use the git add -A command?
Q22. Describe what is happening given these commands:
git checkout feature-user-location
git cherry-pick {123safd23e}
Q23. You find that your project has a tag and branch both named push-notifications, which causes confusion when trying to print out given reference. How can you specify which branch you want to look at?
Explanation
Reference
Q25. What is the operation doing given the Git commands below?
git bisect start
git bisect bad 5d41402abc4b2a76b9719d911017c592
git bisect good 69faab6268350295550de7d587bc323d
Q27. Which of the following is true of the git push command?
Explanation
Reference
Q28. After pushing commits to the remote repository for the first time using the command below, what shorthand command can you use in future?
git push -u origin master
Q29. How would you create a custom shortcut or command across your git environment?
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: beta-notes.js
Q31. What command would let you modify your previous commit?
Q33. What change will the following command make to the staging area files?
git rm --cached testfile.js
Q34. After you've successfully merged two branches and committed the changes, what is the next step in keeping your git structure organized?
Q36. What command would you use to create a new git repository?
Q39. Your current repository has three branches: master, beta and push-notifications. You've just finished the notification feature and commit the changes to the push-notifications branch, and you want to include them in the beta branch. How can you accomplish this?
Q40. Which statement is true of the git push command?.
Explanation
In Git, there are two main ways to integrate changes from one branch into another: the merge and the rebase. Reference
Q49. Which Git command begins tracking of a new file?
Q51. Which key press returns a set of suggestions to pick from, when writing a Git command?
Q53. Which command gets a copy of an existing Git repository?
Q61. What is the difference between initializing a normal repo and a bare repo?
Q64. After staging a series of changes to the index, which command could you use to review them prior to a commit?
Q65. What does the git stash drop command do?
Q66. What command creates a new branch from the currently checked-out branch?
Q68. What happens if you run this command from your master branch?
git checkout -b beta-test
Q72. After modifying some existing files in a repository, you decide to discard the changes. What command can you use?
Q75. Which command correctly creates a lightweight tag?
Q76. What is the main issue with using git rebase when working with multiple developers?
Q77. What Git workflow is used by teams that collaborate on a single branch and avoid creating long-lived development branches?
Q78. Which option on the git log command allows you to limit output to commits made after certain data?
Q81. How does this command alter the currently checked-out branch?
git reset --soft HEAD^
Q82. What is the difference between Git and SVN?
Q84. This command is an example of what kind of tag ?
git tag -a v1.4 -m "ABCD v1.5"
Q85. What is the difference between a soft reset (git reset --soft
) and a hard reset (git reset –hard
) ?
Which of the following options is correct ?
Explanation
Reference