|
1 | 1 | <b> How can you check your current git version?</b><br><ul><li>git --v</li><li>git --version</li><li>git --option</li><li>git --current</li></ul>,git --version
|
2 |
| -"<b> What command lets you create a connection between a local and remote repository?</b><br><ul><li>git remote add new</li><li>git remote add origin</li><li>git remote new origin</li><li>git remote originThe command is git remote add. The new added connection can be named origin or new. The only constraints, although it is not documented AFAIK, is that the connection name needs to be acceptable to git-check-ref-format, and it cannot be repeated.<br>If the LinkedIn assessment asks this and you can choose just one option, then leave feedback.<br></li></ul>",<ul><li>git remote add new</li><li>git remote add origin</li></ul> |
| 2 | +<b> What command lets you create a connection between a local and remote repository?</b><br><ul><li>git remote add new</li><li>git remote add origin</li><li>git remote new origin</li><li>git remote origin</li></ul>,"<ul><li>git remote add new</li><li>git remote add origin</li></ul><br><br>**Explanation:**<br>The command is git remote add. The new added connection can be named origin or new. The only constraints, although it is not documented AFAIK, is that the connection name needs to be acceptable to git-check-ref-format, and it cannot be repeated.<br>If the LinkedIn assessment asks this and you can choose just one option, then leave feedback.<br>" |
3 | 3 | "<b> Describe what these Git commands do to the commit history:</b><br><br>```bash<br>git reset --hard HEAD~5<br>git merge --squash HEAD@{1}<br>```<br><br><ul><li>They reset the HEAD to the fifth commit in the repo, then merge to the master branch.</li><li>The current branch's HEAD is reset back five commits, then prior commits are squashed into a single commit.</li><li>They delete the last five commits.</li><li>They merge the last five commits into a new branch.</li></ul>","The current branch's HEAD is reset back five commits, then prior commits are squashed into a single commit.<br><br>**Explanation:**<br>- `git reset --hard HEAD~5` resets the current branch to the commit just before the last 5 (see `man gitrevisions` for details about this notation and other cool alternatives like `HEAD@{2 days ago}`). As it is a hard reset, it will also overwrite every change in the working tree as well. See `man git-reset`.<br>- `git merge --squash HEAD@{1}` HEAD@{1} is where the branch was just before the previous command (again, see `man gitrevisions`). This command sets the state of the index to be as it would just after a merge from that commit. This whole operation could be a way to take 5 commits from a branch in which you started a new feature and squash them to a single commit, a meaningful one.<br>"
|
4 | 4 | "<b> 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?</b><br><ul><li>Checkout the push-notifications branch and run git merge beta</li><li>Checkout the master branch and run git merge beta -> push-notification</li><li>Delete the push-notification branch and it will be committed to the master branch automatically</li><li>Checkout the beta branch and run git merge push-notification</li></ul>",Checkout the beta branch and run git merge push-notification
|
5 | 5 | <b> Which of the following is true you when you use the following command?</b><br><br>`git add -A`<br><br><ul><li>All new and updated files are staged</li><li>Files are staged in alphabetical order.</li><li>All new files are staged</li><li>Only updated files are staged</li></ul>,All new and updated files are staged
|
|
13 | 13 | <b> How could you squash multiple commits together without using git merge --squash?</b><br><ul><li>Caching</li><li>You can't. git merge --squash is the only git command for that operation.</li><li>Rebasing</li><li>Reflogging</li></ul>,Rebasing
|
14 | 14 | "<b> If you cloned an existing git repository, what would happen?</b><br><ul><li>A new copy would overwrite the central repository</li><li>A copy of the repository would be created on your local machine</li><li>Nothing, cloning is not a supported git function</li><li>A copy of the repository would be created on the hosting platform</li></ul>",A copy of the repository would be created on your local machine
|
15 | 15 | "<b> How can you display a list of files added or modified in a specific commit?</b><br><ul><li>Find the commit in the remote repository, as that's the only place that kind of information is stored.</li><li>Use the `diff-tree` command with the commit hash.</li><li>Run `git commit --info` with the commit hash.</li><li>Access the commit stash data with `git stash`.</li></ul>",Use the `diff-tree` command with the commit hash.
|
16 |
| -"<b> What files is this .gitignore programmed to leave out?</b><br><br>```shell<br>#.swift<br>build/<br>*.txt<br>*.metadata<br>```<br><br><ul><li>All files with a .swift, .txt, or metadata file extension, as well as the entire build directory</li><li>Only the build directory</li><li>All files in the build directory, as well as files ending with .txt or .metadata</li><li>Only files with .swift and .txt extensions.A line starting with `#` serves as a comment. Hence `# .swift` does not do anything. See `man gitignore`.<br></li></ul>","All files in the build directory, as well as files ending with .txt or .metadata" |
| 16 | +"<b> What files is this .gitignore programmed to leave out?</b><br><br>```shell<br>#.swift<br>build/<br>*.txt<br>*.metadata<br>```<br><br><ul><li>All files with a .swift, .txt, or metadata file extension, as well as the entire build directory</li><li>Only the build directory</li><li>All files in the build directory, as well as files ending with .txt or .metadata</li><li>Only files with .swift and .txt extensions.</li></ul>","All files in the build directory, as well as files ending with .txt or .metadata<br><br>**Explanation:**<br>A line starting with `#` serves as a comment. Hence `# .swift` does not do anything. See `man gitignore`.<br>" |
17 | 17 | "<b> After you make changes to a local repository, you run the following command. What will this do?</b><br><br>`git commit -a -m ""Refactor code base""`<br><br><ul><li>Nothing, you can't use multiple options in the same command</li><li>Adds all new files to the staging area</li><li>Commits all new files with a message</li><li>Adds all modified files to the staging area, then commits them with a message</li></ul>","Adds all modified files to the staging area, then commits them with a message"
|
18 | 18 | "<b> After checking your git status you get the following output, which shows the file beta-notes.js in the commit but also unstaged. How can this situation occur?</b><br><br>```shell<br>Change to be committed:<br>(use ""git reset HEAD <file>..."" to unstage)<br>modified: beta-notes.js<br>Changes not staged for commit:<br>(use ""git add <file>..."" to update what will be committed)<br>(use ""git checkout --<file>..."" to discard changes in working directory)<br>modified: beta-notes.js<br>```<br><br><ul><li>There were two copies of beta-notes.js but one was deleted</li><li>beta-notes.js was staged, then modified afterwards, creating two different versions of the file</li><li>Two copies of beta-notes.js were created, but only one is being tracked</li><li>There are two tracked copies of beta-notes.js, but one was removed from the commit</li></ul>","beta-notes.js was staged, then modified afterwards, creating two different versions of the file"
|
19 | 19 | <b> Where are files stored before they are committed to the local repository?</b><br><ul><li>Saved files</li><li>git documents</li><li>Staging area</li><li>git cache</li></ul>,Staging area
|
20 |
| -"<b> What commands would you use to force an overwrite of your local files with the master branch?</b><br><ul><li>⠀```bash<br>git pull --all<br>git reset --hard origin/master<br>```<br></li><li>⠀```bash<br>git pull -u origin master<br>git reset --hard master<br>```<br></li><li>⠀```bash<br>git pull origin master<br>git reset --hard origin/myCurrentBranch<br>```<br></li><li>⠀```bash<br>git fetch --all<br>git reset --hard origin/master<br>```<br>- The command `pull` is `fetch` followed by either `merge` or `rebase` (in this case, `merge`). We don't want to merge. Merge would be an action to our **repository**. We just want to overwrite our **local files**.<br></li></ul>","⠀```bash<br>git fetch --all<br>git reset --hard origin/master<br>```<br>- The command `pull` is `fetch` followed by either `merge` or `rebase` (in this case, `merge`). We don't want to merge. Merge would be an action to our **repository**. We just want to overwrite our **local files**.<br>" |
| 20 | +<b> What commands would you use to force an overwrite of your local files with the master branch?</b><br><ul><li>⠀```bash<br>git pull --all<br>git reset --hard origin/master<br>```<br></li><li>⠀```bash<br>git pull -u origin master<br>git reset --hard master<br>```<br></li><li>⠀```bash<br>git pull origin master<br>git reset --hard origin/myCurrentBranch<br>```<br></li><li>⠀```bash<br>git fetch --all<br>git reset --hard origin/master<br>```<br></li></ul>,"⠀```bash<br>git fetch --all<br>git reset --hard origin/master<br>```<br><br><br>**Explanation:**<br>- The command `pull` is `fetch` followed by either `merge` or `rebase` (in this case, `merge`). We don't want to merge. Merge would be an action to our **repository**. We just want to overwrite our **local files**.<br>" |
21 | 21 | <b> Which statement is true when you use the git add -A command?</b><br><ul><li>Only new files in the working directory are staged to the index.</li><li>All new and updated files from the working directory are staged to the index.</li><li>All files in the working directory are staged to the index in alphabetical order.</li><li>Only updated files in the working directory are staged to the index.</li></ul>,All new and updated files from the working directory are staged to the index.
|
22 | 22 | "<b> 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?</b><br><ul><li>use git show refs/push-notifications</li><li>use git show push-notifications</li><li>use git show heads/refs/push-notifications</li><li>use git show refs/heads/push-notifications</li></ul>",use git show refs/heads/push-notifications<br><br>[Reference](https://geedew.com/fixing-git-branch-and-tag-name-collision/)<br>
|
23 | 23 | <b> Your team lead needs a list of all commits that will be moved before you perform a rebase. Which command can you use to access that information?</b><br><ul><li>git rebase -log</li><li>git rebase -i</li><li>git rebase -verbose</li><li>git rebase -all</li></ul>,git rebase -i
|
|
0 commit comments