A team member has made several updates to files in a local Git repository. To prepare for the next commit, the team member wants to stage a specific file called update.txt that has been modified along with various other files. Which command should the team member use to stage only the changes in update.txt?
The correct answer is git add update.txt because it stages the specific changes made to update.txt, making it ready for the next commit. The git add . command would stage all changes in the current directory and subdirectories, which is not desired in this scenario if the intention is to only stage update.txt. Using git commit update.txt without the add command would not work because commit attempts to create a new commit from currently staged changes, and it does not accept a file path as an argument. git push update.txt is incorrect because push is used for updating remote refs along with associated objects, not for staging changes.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the command 'git add' do in Git?
Open an interactive chat with Bash
What is the difference between staging and committing in Git?
Open an interactive chat with Bash
What happens if I use 'git add .' instead of 'git add update.txt'?