Version Control

¡Supera tus tareas y exámenes ahora con Quizwiz!

What is not a way to use version control? - using an "undo" tool to revert a mistaken change -using SCM when making changes to a text file -making changes to an image file and saving the new version to the same file -copying a spreadsheet to make changes in a separate file

- making changes to an image file and saving the new version to the same file (Without saving previous versions of the file separately, no changes are tracked)

What is the conventional file name to ensure an otherwise empty directory is included in the repository?

.gitkeep Using .gitkeep for the filename is the convention, though any file name is acceptable.

If the HEAD is pointed to commit 1b34c8 on the master branch when commit 43c562 occurs, where will HEAD point if the branch changes from master to test, and then back to master? 1b34c8 the child of 43c562 the head of the test branch 43c562

43c562 When changing branches, Git remembers the HEAD of the previous branch and will resume at that commit when the user returns to that branch.

What will git init write to a directory? -The files of the named repository -A .git directory -Both repository files and the .gitconfig file -The .gitconfig file

A .git directory git init initializes the directory with a .git directory containing project-specific files.

How can you recover data from a deleted .git directory? -A deleted .git directory's contents cannot be recovered. -Run git init and git config to recreate the contents. -Copy the project's .git contents from /etc/git/ or Program Files\Git\etc\. -Reconstruct it from the .git directory in a project's subdirectory.

A deleted .git directory's contents cannot be recovered. Git keeps all project tracking data in the .git directory, and when it is deleted, all the tracking data goes with it.

How might users make use of Git's version control capabilities? -A graphic artist can use Git's built-in tools to create and edit multiple versions of a single image. -A development team can use Git to evaluate version differences before prior to new changes into the production code base. -An author can use Git to track and combine separate files with chapters of a technical book containing code. -An open source development group can use Git to test new code before incorporating the code into their final release.

A development team can use Git to evaluate version differences before prior to new changes into the production code base. (Git's strengths lie in its ability to allow multiple users to contribute to a repository, and the repo owner can easily evaluate proposed changes with Git's tools.)

When viewing the contents of a tree object (directory), you will see an identifier column that labels an item as either a tree or a blob. How would you define these? -A tree is a directory in another project, and a blob is a file. -A tree is a subdirectory within the directory, and a blob is a file. -A tree is a subdirectory within the directory, and a blob is a tree in another project.

A tree is a subdirectory within the directory, and a blob is a file.

How is staging an edited file different from staging a new file? -Both require git commit to stage them. -New files do not need to be staged. -Both require git add to stage them. -Edited files do not need to be staged.

Both require git add to stage them. git add will stage any file, regardless of the kind of change it has created in the repository.

Using git status reveals Git does NOT see the directory "css". What steps can you take to troubleshoot?

Ensure css/ does not appear in the .gitignore file, and ensure there is a file of any type in the directory. There is a third location to check, as well -- the file at .git/info/exclude in the repository.

After editing a file, you use the command git add. What is the result? -Error: git init must be used to stage the files. -Error: No files were specified when invoking git add. -The most recently edited file is staged and ready to be committed with git commit. -All files are staged and ready to be committed with git commit.

Error: No files were specified when invoking git add. Correct Either the names of files to be added or a period (.) must be passed as an argument to git add so git knows which files to stage.

If you find small tracking files in every directory, what do you know about your version control? -The version control is an old version of Git. -There is too little information to determine the version control. -The version control is a recent Git release. -The version control is not Git.

The version control is not Git.

What is the result of the following command: git commit -a -Git will open a text editor for a commit message and commit all files with changes. -Commit will be queued until a message is added to COMMIT_EDITMSG. -Commit will fail due to the lack of commit message. -Git will commit all files with changes with a blank commit message.

Git will open a text editor for a commit message and commit all files with changes. The core.editor config value will determine which text editor is opened to accept a commit message.

If you have just completed editing two files, what is the result of the following series of commands, executed without any other action? git add . git commit -m "Initial commit" git add . git commit -m "Another commit" -There will be no change to the repository. -Git will stage the first edited file and commit it with "Initial commit" and then will stage and commit the second file with the commit message "Another commit." -Git will return an error at the Initial commit. -Git will stage both files and commit them with the message "Initial commit." The next set of add and commit messages will have no effect on the repository.

Git will stage both files and commit them with the message "Initial commit." The next set of add and commit messages will have no effect on the repository. git add . will stage all changed files in the repository, so the Initial commit will commit changes to both edited files. The second set will not change anything, as there will be no changed files to stage or commit.

f you view the contents of .git/HEAD and find the contents below, what do you know about the HEAD pointer? ref: refs/heads/new -HEAD currently points to a commit in branch new. -The commit HEAD points to will be the parent of the next commit on the master branch. -HEAD currently points to the newest commit. -The SHA for HEAD can be found in the file at ~/refs/heads/new.

HEAD currently points to a commit in branch new. The .git/HEAD file indicates the branch HEAD currently points to, and the contents of the file will contain the SHA of that branch's HEAD. If you checkout another branch, the contents of .git/refs/heads/new will not change, but the .git/HEAD contents will.

Which is NOT a way to gain access to Git on a Mac? -Install Git with the HomeBrew command brew install git. -Install Git with the terminal utility command install git. -Install Git with the Git installer from git-scm.com. -Use the pre-installed version on newer Macs.

Install Git with the terminal utility command install git. The terminal utility on a Mac does not have an install command. HomeBrew commands can be used on the terminal command line instead.

Why is Git so much more powerful than earlier version control systems? -It is open source and runs on multiple operating systems. -It is open source, fast, and is distributed. -It is fast, can handle large code bases, and is distributed. -Developers can work concurrently on files.

It is fast, can handle large code bases, and is distributed. (Torvalds needed Git to work well for Linux, so it needed to be fast, handle the entire kernel base, and be accessible to the open source community.)

Why is Git auto-completion useful?

It speeds up typing commands.

Which of these methods is best to deal with a file called this_file.txt that should NOT be deleted but should no longer be referenced when git status is used? -Move this_file.txt from the project directory so Git will no longer reference the file. -Use git rm this_file.txt to remove this_file.txt from the project without deleting it. -Rename the file to this_file2.txt, and use git rm this_file.txt. Then rename this_file2.txt back to this_file.txt. -Move this_file.txt from the project directory and use git rm this_file.txt to remove the file.

Move this_file.txt from the project directory and use git rm this_file.txt to remove the file. Though it's possible to instruct Git to ignore a file in the project directory, moving a file from the directory will result in a prompt from git status to remove the file with git rm, and executing this instruction means the file will no longer be tracked or noticed by Git.

What is the effect if a file in the main repository becomes corrupted? -Local copies must be deleted to avoid corruption. -Local copies will become corrupted but can be reverted. -Local copies are at risk, and all work on them should stop. -There is no effect on users' local copies.

There is no effect on users' local copies. (Because Git is distributed, the file in users' repositories will be unaffected by any changes to the file in the main repository unless users attempt to retrieve the corrupted file.)

If a bad actor tampers with a file in an old version of a repository, which is true? -Git would not be able to identify any issue until the old version is accessed. -Git will disregard the old version SHA-1 because of the age of the commit. -The changed checksum would generate an error on access of that version or a descendant. -The bad actor would also need to alter the SHA-1 for that commit to avoid detection.

The changed checksum would generate an error on access of that version or a descendant. The hashing algorithm uses the commit ancestry to compute a SHA-1, so all descendents of the altered commit would have invalid SHA-1 checksums.

What is the purpose of using git --version after Git's installation on a Windows system? -The command finalizes installation and sets up the Git environment. -The command outputs the current version of Git, confirming a successful installation. -The command outputs whether the version installed is the most current version available. -The command deletes unneeded files from previous Git versions.

The command outputs the current version of Git, confirming a successful installation. Using any Git command after installation will confirm Git is installed, but requesting the current version of the tool is an easy way to confirm with minimal output and no need to set up a repository.

How does committing an edited file affect the Git architecture's trees? -The commit moves the file from the working directory to the staging index. -The commit moves the file from the staging index to the repository. -There is no effect on the trees. -The commit moves the file from the repository to the working directory.

The commit moves the file from the staging index to the repository. Just like adding a new file to the repository, committing the file moves it from the staging index to the repository.

What commit message will appear in git log --oneline for a commit if no commit message was provided? -NO MESSAGE will replace the missing message. -Empty commit message will replace the missing message. -The message will be blank. -The commit will not appear in the log.

The commit will not appear in the log. When Git is not provided a commit message, it will abort the commit. Using the "-m" option with empty quotes has the same result as exiting a text editor without providing a message.

You have made edits to file1.txt and then execute git add file1.txt and git commit -m "commit message". You edit the file again. What steps are required to move the file to the working directory? The file is already in the working directory. git add file1.txt git log git commit -m "New commit"

The file is already in the working directory. The file is always in the working directory. Its content will not agree with the staging directory until contents have been staged, and its contents will not agree with the repository until contents have been committed.

After adding a file to your .gitignore, you type git status and see the file listed as untracked. Why is the .gitignore inclusion NOT successful?

The file was tracked before inclusion in .gitignore. Running git rm --cached <filename> will remove the file from tracking, and Git will begin to ignore it.

Why might packaging and distribution files and directories be included in a .gitignore template? -The files are not edited as source code is. -There is no reason -- these files should still be tracked. -The files take up too much memory. -The files will not change very often.

The files are not edited as source code is. .gitignore should include any files that do not need to be tracked by Git, including those that will not be edited by developers but that might change.

Why might a user choose NOT to include a .gitignore file in the repository? -The .gitignore should always be included in the repository. -The .gitignore file might contain sensitive user information. -Execution of .gitignore would result in file deletions. -The files to be ignored are user- or system-specific.

The files to be ignored are user- or system-specific. Files specific to a user's development environment, account, or computer system are neither needed in a repository nor are they advisable additions to a repository for the sake of security, particularly if the repository is shared and not used only locally.

You decide to start a new project, so you open a command line window and type git init. What issue will you likely encounter? -The command requires more information, so the repository will not be initialized. -The location of the repository will include unrelated files and directories. -Another Git command is required before git init, so the repository will not be initialized. -The .git directory will not be created with the necessary files and subdirectories.

The location of the repository will include unrelated files and directories. By not creating a directory for the repository and changing into that directory before typing git init, all the home directory files and any sub-directories created will need to be included in an ignore list for Git. Any new directory created in the home directory going forward will need to be added to that list, as well.

If the output of git status reveals that file file1.php is untracked, what is true about the file? -Git does not recognize file1.php. -There have been no changes made to file1.php. -Git will not be able to stage file1.php. -There will be no record of further changes made on file1.php.

There will be no record of further changes made on file1.php. Until the file has been staged with git add, changes will not be recorded by Git.

What is the most efficient way to rename a file in a repository? -Use git mv with the file name. -Rename the file with the operating system's tools and execute git rm to delete the old file name from the repository. -Rename the file with the operating system's tools and use git add and git rm to replace the old filename with the new one. -Use git rename with the file name.

Use git mv with the file name. git mv is the most efficient way to both move a file to a new location and rename the file.

If project files undergo changes a, b, and c, which changes will be added to the following commit: [change a is made] git add . [change c is made] [change b is made] git add . git commit -m "Commit Message" b and c a and b a and c a, b, and c

a, b, and c Change a is staged before changes b and c are staged together, so all three changes will be committed.

Which single-line commit message uses best practices? -temporary change to user notice for PSM requirements -- needs follow-up after the new year -form submission error on customer query contact form -adds dashboard feature to display client usage log summary as pie chart -changed cookie expiration to eliminate login timeout issue

adds dashboard feature to display client usage log summary as pie chart This message is written in present tense, gives an overview of the change made in the commit, stays within character limits, and does not include unnecessary information.

Which is the correct order of the following actions to commit a single change to the repository? A. git commit B. git diff C. Edit the file. D. Add a multi-line commit message. E. git add

c, b, e, a, d

Which best describes the typical basic Git workflow? -create new or edit existing files, stage the files, commit the files -create new files, commit the files, edit files, stage the files, commit the files -create new or edit existing files, commit the files, add the files -create new files, add the files, edit files, commit the files, add the files

create new or edit existing files, stage the files, commit the files Though the workflow might differ according to the needs of the project, the essence of the workflow is change files, stage, and commit.

Which of these should NOT generally be included in the .gitignore file? -user's IDE configuration files -directories containing project code -files created during runtime -package manager directories

directories containing project code Because these are text files in development, with changes that might require reversion, codebase directories should as a general rule not be included in the .gitignore file.

Assuming the following Git commands are available, what would you need to type in order to auto-complete "git pull"? patch-id prune pull push

git pul & [tab]

The output of git status is the following text, the last line in green: Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: file1.php -file1.php was deleted from the repository, followed by git add file1.php -the file was deleted by using the command git rm file1.php -file1.php was deleted with an operating system tool rather than git rm file1.php -file1.php was moved from the repository, followed by the command git add file1.php

file1.php was deleted with an operating system tool rather than git rm file1.php Green text denoting a file deletion means this deletion has already been staged for the next commit. If a file is deleted without using git rm, the deletion notice from git status will be red.

A user is unsure of the version of Git installed. Which command should they use?

git --version

By using git commit -am, which command has been made redundant?

git add Using the -a option with git commit skips the staging tree and directly commits all changes, so files do not need to be staged with git add.

If a user must use git reset HEAD tabs.js to unstage tabs.js, which command likely created the need to reset the HEAD? -git status tabs.js -git log -git add . -git init

git add . If the file tabs.js must be unstaged, it was staged with either git add tabs.js or git add .. This might become necessary in situations where the user does not wish to add a file to the repository or even does not want the current changes in that file to be part of the next commit.

Besides accessing a project's .git/config file, how can you change its contents? -git config -git config --repository -git config --project -git configure

git config Git config with no options will access the project-level config file.

What command should you use to ensure all projects you work on have black and white output? -git config --global color.ui false -git config --local color.ui false -git config --local color false -git config --global color false

git config --global color.ui false Git's color.ui configuration is by default set to "auto", so it colorizes output to help users visually parse the output quickly, except when output is piped or redirected to a file. To turn colors off, you need only set color.ui to false for all output.

Which will return the diff of the next commit's parent with the commit identified by SHA a8b0cd? Assume the older commit's parent SHA is 682bcd.

git diff 682bcd..HEAD Two equivalent alternatives are git diff 682bcd.. and git diff a8b0cd^..HEAD. Git will use HEAD if a commit is not specified on one side of the "..", and the caret (^) refers to the SHA's parent commit.

You are considering using the ls-tree command and want to see the options available for that command. Which command will you use?

git help ls-tree

Which command identifies the hash you can use in git show?

git log Git's log will list the hash for each commit, allowing the user to quickly identify the SHA for the commit they wish to view.

Which filter command will show commits that happened between two weeks ago and three days ago?

git log --after=2.weeks --before=3.days

When using the git log command, which option will provide an output of the log with the hash column shortened?

git log --oneline

Which will output the log for all of Karen's commits labeled "refactor" during March 2019? git log --since=2019-03-01 --until=2019-03-31 --author="Karen" --grep="refactor" git log from=2019-03 until=2019-03 name="Karen" grep="refactor" git log since="2019-03-01" until="2019-03-31" author="Karen" grep="refactor" git log --from=2019-03 --until=2019-03 --name="Karen" --grep="refactor"

git log --since=2019-03-01 --until=2019-03-31 --author="Karen" --grep="refactor" The --since and --until narrow the date, --author defines the commit's author, and --grep will search for all commits that include "refactor" in the description.

Which will output the log for the last two commits that happened before September 10, 2020? git log 2 --until=2020-09-10 git log --until=2020-09-10 --n 2 git log --until=2020-09-10 -n 2 git log -limit 2 --until=2020-09-10

git log --until=2020-09-10 -n 2 The --until option defines the end date for logs to output and -n 2 limits to the two most recent.

What steps can a user take to remove a personal file from the repository while keeping a local copy that won't be tracked by Git?

git rm --cached personal.txt add personal.txt to .gitignore git commit -a Using the "--cached" option with git rm will remove the file from the index without affecting the local copy. When the file name is then added to .gitignore and all changes committed to the repository, the local copy will remain but will no longer be seen by Git.

Which command would allow a user to view the changes of a past commit with the SHA that begins with 94ff81a? The command should highlight word changes rather than line changes.

git show --color-words 94ff81a To view a commit's diff, the git show command is needed. Like git diff, it takes the --color-words option.

Which kind of file might be included in the file generated by this command: git config --global core.excludesfile ./.gitignore_user -the Composer directory managing packages for the company website -the index.html file that appears in different versions in every repository -log files created by multiple projects in separate repositories -all files listed in each .gitignore that exists in a development directory

log files created by multiple projects in separate repositories Log files are created during run-time, so they are not ideal files to track in version control.

Besides using git help cherry-pick, how might you view the information for the cherry-pick command on Linux? -man git-cherry-pick -man git -cherry-pick -less .git/cherry-pick -less .git/git-cherry-pick

man git-cherry-pick The man page for git-cherry-pick is identical to the output from the git help cherry-pick command, since the help command is essentially an interface for the git man pages.

What elements of good practice were ignored in creating this commit message: PS-1024: Extends NLP model Must confirm with Deep Learning group that model is latest version. -first line is too long -should use past tense -not enough detail -first line uses a label

not enough detail The first line is short, but the following information doesn't actually address what the code change accomplishes. An additional issue is the inclusion of information that should appear in the issue tracking system or task list rather than in a commit message.

If viewing a diff of an edited file displays a single unchopped line, and edits are highlighted by word instead of by line, which commands were used? -on the command line: git diff --color-words In the diff paginator: -S -on the command line: git diff -S In the diff paginator: --color-wrap -on the command line: git diff -S In the diff paginator: --color-words -on the command line:git diff --color-wrap In the diff paginator: -S

on the command line: git diff --color-words In the diff paginator: -S Invoking diff with --color-words will highlight changes by word rather than by line. Using -S will toggle line wrapping. Word-wise changes can also be formatted with --word-diff.

Which tree in the Git architecture does NOT require a Git command to move file changes to that tree? the working directory the repository the staging index all three trees require a Git command to move file changes into them

the working directory In the working directory, the user can create new files or change existing files that do not yet exist in either the staging index or the repository, and no Git command is required to do so.

In which situation should you use git diff? -to observe how two different versions of code will execute -to view two side-by-side versions of a file in full -to observe specific changes from the original version of a file -to observe the difference in the memory required by two versions of code

to observe specific changes from the original version of a file git diff displays only the lines that have changed between two versions of a file.


Conjuntos de estudio relacionados

Hunter Safety Chapter 6-9 Lucieo E.

View Set

Anatomy- Female Internal Genitalia

View Set

Managerial Accounting Chapter 10 Review

View Set

Cybersecurity Management I - Strategic - C727 PreAssessment Test

View Set