I recently received a “forced update” warning from git on a repository which only I commit to. I haven’t done any re-basing so I don’t know why this happened. What I want to know is, where should I look to find changes that have potentially been lost?
To illustrate, let there be three copies of the repository, L, D and S (laptop, desktop, server).
To begin all three repositories are in-sync. Then work is done on D and pushed to S. Then L runs git pull and gets “forced update”. Does this mean that there are changes made on L that have been overwritten, or are they somewhere else? How can I find them? Thanks.
A “forced update” means the remote-tracking branch was recent. This happens if you fetch (or pull) after someone does a force push to the repository.
However, when executing the
git pull, your local branch won’t lose any history. Since the remote branch’s history now diverges from your local,git pullwill execute a merge. If you look at the most recent commit (just rungit log) you should see a merge commit, with the first parent being the previous state of your local branch and the second parent being the new value of your remote branch.For illustration, I just reproduced the forced update scenario, and a
git pullprints the following:The fetch portion of the pull prints
(forced update), but the new value oforigin/masteris subsequently merged into the local branch.