Reset to the latest valid commit based on TortoiseGit
1. In the submission of a developer, there is a conflicting file, and the conflict is forced to submit, as shown in Figure 1
2. Decide to delete several possible conflicting files to delete, and reset the version to the latest valid submission, as shown in Figure 2
3. Select hard reset, and discard all subsequent commits directly, as shown in Figure 3
4. The reset is successful, as shown in Figure 4
git.exe reset --hard 086fc817cc3d149adf8ebc0489d75b3958ea111f --
HEAD is now at 086fc81 Merge remote-tracking branch 'origin/develop' into develop
成功 (593 ms @ 2019/03/18 18:21:37)
5. The local file has been restored to the latest valid submission, and the conflict prompt has disappeared, as shown in Figure 5
6. When pushing, you need to pull the code first, but the code should not be pulled at this time, otherwise, the conflicting file will be pulled down, as shown in Figure 6
git.exe push --progress "origin" develop
To https://gitlab.chinamcloud.com/php/pcs-api.git
! [rejected] develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://gitlab.chinamcloud.com/php/pcs-api.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git 未能顺利结束 (退出码 1) (2657 ms @ 2019/03/18 18:30:15)
7. Force the content to be pushed to the remote server, as shown in Figure 7
git.exe push --force-with-lease --progress "origin" develop
Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: To create a merge request for develop, visit:
remote: https://gitlab.chinamcloud.com/php/pcs-api/merge_requests/new?merge_request%5Bsource_branch%5D=develop
remote:
To https://gitlab.chinamcloud.com/php/pcs-api.git
+ b04e465...086fc81 develop -> develop (forced update)
成功 (4156 ms @ 2019/03/18 18:51:42)
8. View git on gitlab Submit log on the server, found that the latest commit ID has been restored to: 086fc817cc3d149adf8ebc0489d75b3958ea111f, as shown in Figure 8







