Consider the 2nd scenario in git pull --rebase lost commits after coworker's git push --force :
--rebase
, and observes his history lost.In an online test, I was asked the following question.
How can Dan compare the changes before and after the
git pull --rebase
?
I was required to respond with one single complete git command.
If I were actually working on my local repo, I would use git reflog
to retrieve the appropriate commit IDs for git diff
, but in the online test, I wasn't given such details.
Question source: online test on Codingame
A 3rd-party user rebased accidentally and incorrectly, and then force pushed it. You pulled these changes into your local repo and lost all commit history.
What command can you execute to list all changes of the repo so that you can come back to a former state corresponding to a given reference?
I tried inputting git reflog
today, and the online test system accepted it.
git reflog
is the command that retrieves the past git references that a user stayed, so that's the best response for the question.