exam questions

Exam 350-901 All Questions

View all questions & answers for the 350-901 exam

Exam 350-901 topic 1 question 12 discussion

Actual exam question from Cisco's 350-901
Question #: 12
Topic #: 1
[All 350-901 Questions]

DRAG DROP -
Drag and drop the steps from the left into the correct sequence on the right to describe how to use Git to maintain the current HEAD and revert back to a previous commit, while undoing all intermediate commits.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
wilie
Highly Voted 1 year, 3 months ago
Step 1 --------- > git log (Show the log of commits) Step 2 --------- > git reset hard 56e05fced (Revert to original “add”) Step 3 --------- > git reset -–soft HEAD@{1} (Revert to previous git add) Step 4 --------- > git commit -m “Revert to 56e05fced commit” (Commit the original Head) Step 5 --------- > git status (Confirm status of log) You alway want to check it a command was successful by checking the status.
upvoted 12 times
...
blezzzo
Highly Voted 3 years, 2 months ago
Step 1 --------- > git status (Confirm status of log) Step 2 --------- > git log (Show the log of commits) Step 3 --------- > git reset -–soft HEAD@{1} (Revert to previous git add) Step 4 --------- > git reset hard 56e05fced (Revert to original “add”) Step 5 --------- > git commit -m “Revert to 56e05fced commit” (Commit the original Head)
upvoted 9 times
kayleen
2 years, 11 months ago
This is incorrect. If you try this, git commit will tell you there's nothing to commit - because git reset --hard is exactly what is says -> go back in time to commit 56. You need to first do git log to find the commit number (56...). Then you do git reset --hard 56 to go back to that commit (this will only reset your local branch, your remote if you have it is still at the commit you had at the beginning). Then you do git reset --soft HEAD@{1} which will go back to where you were before git reset --hard BUT it will leave the files alone (how they were at 56). And at this point you can do git commit. This last commit will be on top of what you had at the beginning but the files will be from 56. Which is what the commit says.
upvoted 16 times
JM_Lee
2 years, 9 months ago
I agree with kayleen's opinion. If you do as blezzo's solution, you can see the message "nothing to commit" in 5 step. If I rewrite it according to Kylin’s opinion, it will as following. 1. git log 2. git reset --hard 56e05fced 3. git reset --soft HEAD@{1} 4. git status 5. git commit -m "Revert to 56e05fced commit" For verification, you can check while making two commits.
upvoted 29 times
...
kayleen
2 years, 11 months ago
The commit being on top of the one from the start is important if you want to push to remote.
upvoted 3 times
dead_beef
2 years, 6 months ago
Very interesting, thanks kayleen. Just tested on a dummy repo and you're totally right :o)
upvoted 3 times
...
...
...
...
adomes
Most Recent 6 months, 3 weeks ago
the answer correct Step 1 -> git status Step 2 -> git log Step 3 -> git reset --soft HEAD@{1} Step 4 -> git reset --hard 56e05fced Step 5 -> git commit -m "Revert to 56e05fced commit"
upvoted 1 times
adomes
6 months ago
Sorry I am agree with JM_Lee
upvoted 1 times
...
...
bluesky2022
1 year, 3 months ago
hard reset before soft reset
upvoted 2 times
...
phc1978
2 years, 5 months ago
git reset –hard f414f31 git reset –soft HEAD@{1} git commit -m “Reverting to the state of the project at f414f31”
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago