【已解决】git 撤销上次提交后修改文件再次提交 触发:Cannot do a soft reset in the middle of a merge

文章目录


记录一次 git 操作


一、问题

git 撤销上次提交后修改文件,然后同步触发以下命令及报错(报错来源与git输出面板)

同步包含两步:

  • pull
  • push

git pull

error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

此次合并未处理(变更记录未覆盖任何冲突处)

git pull

error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.

此次合并未处理干净(变更记录未完全覆盖所有冲突处)

git pull

error: Your local changes to the following files would be overwritten by merge:
	path/file
Please commit your changes or stash them before you merge.
Aborting

此次拉取前未提交合并

git push

error: failed to push some refs to '...'
hint: Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g.'git pull ...') before pushing again.

此次 push 之前未进行 pull

git reset --soft HEAD~

fatal: Cannot do a soft reset in the middle of a merge.

此命令适用于本地记录合并,对于以提交到远程的并不适用

二、解决

  1. git reset --merge

注:取消合并

  1. git rebase

注:将当前分支重新设置基线

后续即可正常进行冲突合并以及代码同步

猜你喜欢

转载自blog.csdn.net/qq_32682301/article/details/130489603