Git rollback locally, modify code again, and push to remote problem

  git, question

The operation steps are as follows:
1. Localgit reset --hard commit idFall back to a certain version
2. After the version was rolled back, the local code was modified without pushing to the remote.
3. push to remote after modification, prompt to pull first
The problem is that pull remote code will overwrite the local modification.

How can I operate to push the locally modified code to a remote location?

Why?pull. . .

At first it was like this:

A-B-C-D remote
 A-B-C-D local

The first step,git reset --hard B

A-B-C-D remote
 A-B local

The second step is to modify the local code and record it as e

A-B-C-D remote
 A-B-E local

Pull remote code

A-B-C-D remote
 A-B-E-D 'local

Among them, d’ includes changes to c and d becausegit pullEquivalent togit fetchAddgit merge. At this timemerge“Fetched HEAD” means remoteD. At the same time,D'The message of should have a “merge … from …..”

If you wish to be remoteA - B - E, then don’tpull, directlygit push -f