nerdexam
Cisco

200-901 · Question #502

A developer is working on a new feature named 'feat434370483' in a branch. A file named 'devasc321345515.jpg' has accidentally been staged. The developer needs to remove this so that the commit is…

The correct answer is B. get reset HEAD devasc321345515.jpg. The correct Git command to unstage a file is 'git reset HEAD <filename>'. This removes the file from the staging area (index) without deleting the file or its changes from the working directory - the file simply goes back to being untracked/modified. Note that Choice B contains…

Software Development and Design

Question

A developer is working on a new feature named 'feat434370483' in a branch. A file named 'devasc321345515.jpg' has accidentally been staged. The developer needs to remove this so that the commit is performed and branches are merged. Which Git command must be used to unstage the file?

Options

  • Aget delete HEAD devasc321345515.jpg
  • Bget reset HEAD devasc321345515.jpg
  • Cgit remove HEAD devasc321345515.jpg
  • Dgit revert HEAD devasc321345515.jpg

How the community answered

(52 responses)
  • A
    2% (1)
  • B
    92% (48)
  • C
    4% (2)
  • D
    2% (1)

Explanation

The correct Git command to unstage a file is 'git reset HEAD <filename>'. This removes the file from the staging area (index) without deleting the file or its changes from the working directory - the file simply goes back to being untracked/modified. Note that Choice B contains a typo ('get' instead of 'git'), but it is still the intended correct answer. Choice A uses 'get delete', which is not a valid Git command. Choice C uses 'git remove', which does not exist. Choice D, 'git revert', is used to undo a commit, not to unstage files.

Topics

#Git#Version Control#Unstaging files#Developer workflow

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice