如何用Travel端Git强制覆盖Remote仓库解决合并冲突?
解决方案:强制用Travel端内容覆盖Remote仓库
因为你确认Travel端的代码是需要保留的最终版本,且不想处理大型KiCad文件的冲突,按以下步骤操作即可:
- 终止当前合并冲突状态
执行git pull后仓库处于合并冲突的混乱状态,先撤销这次合并,回到pull前的干净分支状态:
git merge --abort
- 强制推送Travel端内容覆盖Remote
使用安全的强制推送命令(避免误覆盖未知变更,你作为唯一开发者这个检查不会有阻碍):
git push --force-with-lease origin master
如果完全确定远程没有任何需要保留的变更,也可以用git push --force origin master,但--force-with-lease是更稳妥的选项。
- Home端后续同步
回到Home端后,执行git pull origin master就能获取Travel端的最新内容,完成三台设备的同步。
你遇到的错误及冲突详情:
执行git push时的报错:
(rocket_launcher_flask) mark@octopus:~/python-projects/rocket_launcher_flask$ git push To swordfish:/home/mark/git-repo/rocket_launcher_flask.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'mark@swordfish:/home/mark/git-repo/rocket_launcher_flask.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
执行git pull后的冲突输出:
(rocket_launcher_flask) mark@octopus:~/python-projects/rocket_launcher_flask$ git pull origin master remote: Enumerating objects: 216, done. remote: Counting objects: 100% (216/216), done. remote: Compressing objects: 100% (38/38), done. remote: Total 114 (delta 61), reused 114 (delta 61) Receiving objects: 100% (114/114), 192.30 KiB | 713.00 KiB/s, done. Resolving deltas: 100% (61/61), completed with 54 local objects. From swordfish:/home/mark/git-repo/rocket_launcher_flask * branch master -> FETCH_HEAD 813ae76..e29888c master -> origin/master Auto-merging rocket_launcher_flask.wpu CONFLICT (content): Merge conflict in rocket_launcher_flask.wpu Removing bugs.ods Auto-merging Expansion_Board/rocket_launcher_expansion_board/rocket_launcher_expansion_board.kicad_sch CONFLICT (content): Merge conflict in Expansion_Board/rocket_launcher_expansion_board/rocket_launcher_expansion_board.kicad_sch CONFLICT (file location): Expansion Board/rocket_launcher_expansion_board/rocket_launcher_expansion_board-backups/rocket_launcher_expansion_board-2022-09-13_224453.zip added in e29888c7a685c50c0afe5d290e84ad126b02db6a inside a directory that was renamed in HEAD, suggesting it should perhaps be moved to Expansion_Board/rocket_launcher_expansion_board/rocket_launcher_expansion_board-backups/rocket_launcher_expansion_board-2022-09-13_224453.zip. Automatic merge failed; fix conflicts and then commit the result.
内容的提问来源于stack exchange,提问作者user1045680
相关产品推荐
相关产品推荐

